POV-Ray : Newsgroups : povray.advanced-users : Tangent to two ellipses? Server Time
1 Jul 2024 01:06:37 EDT (-0400)
  Tangent to two ellipses? (Message 11 to 16 of 16)  
<<< Previous 10 Messages Goto Initial 10 Messages
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 10 Messages Goto Initial 10 Messages

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