POV-Ray : Newsgroups : povray.advanced-users : Tangent to two ellipses? Server Time
29 Jun 2024 02:13:41 EDT (-0400)
  Tangent to two ellipses? (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: Tangent to two ellipses?
Date: 17 Oct 2010 15:32:10
Message: <4cbb4f3a@news.povray.org>
Tim Cook <z99### [at] gmailcom> wrote:
> On 2010-10-17 13:23, Alain wrote:
> > No, an ellips is not an unevenly scalled circle. It's close but not
> > quite the same.

> Odd...what is the exact difference?

  I'm not sure there is a difference.

  The canonical form of an ellipse is: x^2/a^2 + y^2/b^2 = 1, where 'a' is
the horizontal radius and 'b' is the vertical radius.

  For the sake of simplicity, let's keep the vertical radius at 1 and only
modify the horizontal radius to get our ellipse. If we wanted a function
in terms of 'x' (so that we can eg. draw the top half of the ellipse), we
would solve 'y', so we get (assuming b=1): y = sqrt(1 - (x/a)^2)

  Now let's take the canonical form of a circle of radius 1: x^2 + y^2 = 1
If we solve 'y', we get: y = sqrt(1 - x^2)

  If we wanted to scale our circle horizontally, we would have to divide
'x' by the scaling factor. In other words, if we want to scale the circle
horizontally by factor 'f', we would have to divide 'x' by 'f'. (For example,
if we wanted to scale the circle to be twice as wide as it is tall, we would
have to divide 'x' by 2.)

  Thus we get: y = sqrt(1 - (x/f)^2), which is exactly the equation for the
ellipse where the vertical radius is 1 and the horizontal radius is 'f'.

-- 
                                                          - Warp


Post a reply to this message

From: Tim Cook
Subject: Re: Tangent to two ellipses?
Date: 17 Oct 2010 20:48:31
Message: <4cbb995f@news.povray.org>
On 2010-10-17 14:22, Le_Forgeron wrote:
> Good luck. (there is 2 t to find in [-pi;pi])

Well, this is a place to start.  If I come up with a tidy generalised 
form, maybe I can make a macro that lets you build two arbitrary 
(non-rotated, at least) ellipses joined by one of their tangents...(ha ha).

-- 
Tim Cook


Post a reply to this message

From: Tim Cook
Subject: Re: Tangent to two ellipses?
Date: 17 Oct 2010 23:55:50
Message: <4cbbc546$1@news.povray.org>
On 2010-10-17 14:22, Le_Forgeron wrote:
> let's a=2/2; /* half of 2 on x*/
> let's b=1.4375/2; /* half of 1.4375 on y */
>
> Contact point (origin) is<x,y>  with
> x = a cos(t)
> y = b sin(t)

ehm...what value are you using for t here?  (it occurs to me that I 
should've been able to figure that out, how you find a point on an 
ellipse...use the same formulas as for a circle, but with different x 
and y radius values)

-- 
Tim Cook


Post a reply to this message

From: Le Forgeron
Subject: Re: Tangent to two ellipses?
Date: 18 Oct 2010 02:59:18
Message: <4cbbf046$1@news.povray.org>
Le 18/10/2010 05:55, Tim Cook a écrit :
> On 2010-10-17 14:22, Le_Forgeron wrote:
>> let's a=2/2; /* half of 2 on x*/
>> let's b=1.4375/2; /* half of 1.4375 on y */
>>
>> Contact point (origin) is<x,y>  with
>> x = a cos(t)
>> y = b sin(t)
> 
> ehm...what value are you using for t here?  (it occurs to me that I
> should've been able to figure that out, how you find a point on an
> ellipse...use the same formulas as for a circle, but with different x
> and y radius values)
> 

Well t is anything in the range [0;2pi](modulo 2pi).
(or [-pi;pi]... and so on)


-- 
Real software engineers work from 9 to 5, because that is<br/>
the way the job is described in the formal spec.  Working<br/>
late would feel like using an undocumented external procedure.


Post a reply to this message

From: bart
Subject: Re: Tangent to two ellipses?
Date: 18 Oct 2010 17:09:42
Message: <4cbcb796@news.povray.org>
Tim Cook wrote:
> I have a spline which I which to simplify to a series of CSGed cylinders 
> and boxes.
> 
> cylinder 1 is located at 0, 0 with major and minor axes of 2 and 1.4375
> cylinder 2 is located at 0.5, 2.875 with maj./min. axes of 1.786, 1.03125
> 
> How do I find the endpoints of the tangent ascending from the left of 
> the lower circle to the right of the upper circle?
> 
> (Also on this spline is needed a tangent descending from the left of the 
> lower circle to intersect point -2.03125, 0.21875, the method of 
> solution of which is probably related to the other problem)

This part if simpler, for the ellipse defined as
x(t)=a*cos(t)+x0;
y(t)=b*sin(t)+y0;

x0=0;
y0=0;
px=-2.03125;
py= 0.21875;
dx=x0-px;
dy=y0-py;
D=(a^2*dy^2-b^2*a^2+dx^2*b^2);

t=atan2(-(a^2*dy^2+dx*dy*D^(1/2))*b, a*(-dx*b^2+dy*D^(1/2))*dy)+pi;
s=atan2(-(a^2*dy^2-dx*dy*D^(1/2))*b, a*(-dx*b^2+dy*D^(1/2))*dy)+pi;

the point on the ellipse for the tangent line
you need through the point (px,py) would be
Q=(x(s),y(s)) = (-1.87534111088024,0.499567815891366)

As for the tangent to two ellipses
xt(t)=a*cos(t)+xt0;
yt(t)=b*sin(t)+yt0;

xs(s)=c*cos(s)+xs0;
ys(s)=d*sin(s)+ys0;

there are two constrains for two unknowns t and s:

tan_ell1 = (+/-) tan_ell2
tan_ell1 =  tan_line

the second parameter s is dependent on t:
s=arctan((+/-)a*d*tan(t)/(b*c));

finally it boils out to a single non-linear equation in t

(ys(s)-yt(t))/(xs(s)-xt(t))= (+/-) b/a/tan(t)

Maple gives an analytic solution, but it is unreasonably long.
Two points to take care of: signs and (+/-) pi to the value of arctangent.


Post a reply to this message


Attachments:
Download 'el00.pdf' (5 KB)

From: scott
Subject: Re: Tangent to two ellipses?
Date: 20 Oct 2010 06:27:52
Message: <4cbec428@news.povray.org>
> No, an ellips is not an unevenly scalled circle. It's close but not quite 
> the same.

I always thought an ellipse was exactly the same as an unevenly scaled 
circle, what's the difference?


Post a reply to this message

From: Alain
Subject: Re: Tangent to two ellipses?
Date: 20 Oct 2010 16:43:46
Message: <4cbf5482$1@news.povray.org>
Le 2010-10-20 06:27, scott a écrit :
>> No, an ellips is not an unevenly scalled circle. It's close but not
>> quite the same.
>
> I always thought an ellipse was exactly the same as an unevenly scaled
> circle, what's the difference?
>
>

I remember a tread some times ago where it was discuced. Along the major 
and minor axis, there is no difference, but about midway, there is a 
very slight difference that was effectively demonstrated graphicaly 
using a scaled sphere and an ellipse made using the analytic formula for 
an isosurface.
When rendered coincidently, using distinct pigments for the scaled 
sphere and the isosurface, there was almost no coincident surfaces 
artefacts, but clearly one or the other pigment visible.

There was also a discussion about elliptical torus also showing that 
slight difference.

Anyway, the difference is prety small and, for all practical purposes, 
can be dismissed.



Alain


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Tangent to two ellipses?
Date: 20 Oct 2010 17:46:36
Message: <4cbf633c@news.povray.org>
Alain wrote:

> When rendered coincidently, using distinct pigments for the scaled 
> sphere and the isosurface, there was almost no coincident surfaces 
> artefacts, but clearly one or the other pigment visible.

actually, I think this just demonstrates you shouldn't
use a raytracer to prove mathematical theorems ;) As Warp
already mentioned the formula for an ellipse is just that
of a circle with non-uniform scaling applied to x and y,
so mathematically it should be identical. But numerical
solving may overswing in a systematic manner depending
on curvature and whatnot.


Post a reply to this message

From: Tim Cook
Subject: Re: Tangent to two ellipses?
Date: 28 Oct 2010 19:06:56
Message: <4cca0210$1@news.povray.org>
A bit of research and fiddling later, I now have a simpler method for 
calculating the angle of tangency for a given point on an ellipse that 
doesn't even involve math beyond basic trig or terribly long equations. 
  It turns out that you can use the fact that an ellipse is just a 
squashed circle to do some indirect figuring.

Given unrotated ellipse at <x,y> with radii <a,b> and an angle T:

Point P <c,d> on ellipse is <a*cos(T)+x,b*sin(T)+y>

Tangent angle at P is:
If major axis is along x, atan2(d,a/cos(T)-c)
If major axis is along y, atan2(b/cos(90-T)-d,c)

That's it.

Now all I need to do is find at what angles for two ellipses the 
equations for the lines are the same.

-- 
Tim Cook


Post a reply to this message

From: Tim Cook
Subject: Re: Tangent to two ellipses?
Date: 29 Oct 2010 00:33:10
Message: <4cca4e86$1@news.povray.org>
On 2010-10-28 18:06, Tim Cook wrote:
> Point P <c,d> on ellipse is <a*cos(T)+x,b*sin(T)+y>
>
> Tangent angle at P is:
> If major axis is along x, atan2(d,a/cos(T)-c)
> If major axis is along y, atan2(b/cos(90-T)-d,c)

err add x and y after using the point for the tangent calculations

-- 
Tim Cook
http://empyrean.freesitespace.net


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.