 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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)
--
Tim Cook
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 17/10/2010 07:38, Tim Cook nous fit lire :
> 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
>
Orientation ?
Are they true ellipses or just scaled circles ?
> How do I find the endpoints of the tangent ascending from the left of
> the lower circle to the right of the upper circle?
Why do you need such endpoints ? (with precision)
Wouldn't an approximation be enough ?
Between 2 non colliding circles, there is 4 tangents. (two are crossings
between the centers, the two others are parallel or crossing on the side
of the smaller circle past its center)
(well, symetry rules along the axis defined by the centers)
>
> (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)
>
The second case is just identical, a point is a 0-radius circle.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2010-10-17 03:05, Le_Forgeron wrote:
> Le 17/10/2010 07:38, Tim Cook nous fit lire :
>> 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
>>
> Orientation ?
0 rotation, major axis along x.
> Are they true ellipses or just scaled circles ?
Er? I thought that's what ellipses were...rather, a circle being a
special case of an ellipse. (One site I looked at mentioned scaling
everything so one ellipse is a unit circle at origin and solving from
there...?)
>> How do I find the endpoints of the tangent ascending from the left of
>> the lower circle to the right of the upper circle?
>
> Why do you need such endpoints ? (with precision)
> Wouldn't an approximation be enough ?
Well, enough precision to get a smooth surface in a render.
Approximation is fine. I'm working at five decimal places right now...
> Between 2 non colliding circles, there is 4 tangents. (two are crossings
> between the centers, the two others are parallel or crossing on the side
> of the smaller circle past its center)
> (well, symetry rules along the axis defined by the centers)
...which is why I (well, tried to) specify the particular one of those
in which I'm interested.
>> (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)
>>
> The second case is just identical, a point is a 0-radius circle.
Figured as much. I vaguely remember asking a similar question about two
/circles/ on this or another group, but two ellipses is...a bit
trickier. Even just being able to figure out the slope of a tangent to
a particular point on an ellipse would be a help.
--
Tim Cook
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 2010-10-17 13:43, Tim Cook a écrit :
>> Are they true ellipses or just scaled circles ?
>
> Er? I thought that's what ellipses were...rather, a circle being a
> special case of an ellipse. (One site I looked at mentioned scaling
> everything so one ellipse is a unit circle at origin and solving from
> there...?)
Yes, a circle is a special case of an ellipse.
No, an ellips is not an unevenly scalled circle. It's close but not
quite the same.
>
Alain
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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?
(Also, it means my question is about finding tangents and points on
scaled circles, not ellipses...)
--
Tim Cook
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 17/10/2010 19:43, Tim Cook nous fit lire :
> ...which is why I (well, tried to) specify the particular one of those
> in which I'm interested.
Ascending left from lower (0,0 ?) to right of upper (0.5,2.875 ?) still
does not say if it is crossing the lines of center or not between the
centers.
>
>>> (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)
>>>
>> The second case is just identical, a point is a 0-radius circle.
>
> Figured as much. I vaguely remember asking a similar question about two
> /circles/ on this or another group, but two ellipses is...a bit
> trickier. Even just being able to figure out the slope of a tangent to
> a particular point on an ellipse would be a help.
>
Well, the tangent vector is shitty, but finding the distance from such
line to a point should allow to bisect the right value.
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)
Direction of tangent (as unit vector, thanks wolfram):<m,n>
m = -a sin(t)/q
n = b cos(t)/q
with (and that the shitty part) q = sqrt(b²cos²t + a²sin²t)
(notice that q is not constant!)
Distance of line to point <i,j>:
i= -2.03125
j= 0.21875
k = sqrt((i-x)²+(j-y)²)
(k is length of point to contact, we need to normalise to have a nice
dot product which we can predict)
value to reach 1: ((i-x)*m+(j-y)*n)/k
(1 is a maximum)
Or using a cross product (the tangent must align...):
(to reach 0, intermediate value): (j-y)*m-(i-x)*n
(and we avoid a square root and might be able to also drop q)
so (j-b cos(t))*sin(t)*(-a) - (i-a sin(t))*cos(t)*b == 0
Good luck. (there is 2 t to find in [-pi;pi])
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tim Cook <z99### [at] gmail com> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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)
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |