POV-Ray : Newsgroups : povray.general : Help! Can anyone figure this math? Server Time
13 Aug 2024 15:22:57 EDT (-0400)
  Help! Can anyone figure this math? (Message 1 to 10 of 22)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Philippe Debar
Subject: Help! Can anyone figure this math?
Date: 28 Aug 1998 17:48:23
Message: <35e71797.0@news.povray.org>
I was totally unable to solve this problem for a pov scene.
I found a workaround, but I am not totally satisfied with it.

The problem is to get a smooth joint between differently
oriented surfaces. In this case, two boxes rotated around
the z-axis. I wanted to use a scaled cylinder (to get an
ellipse). What are (1) the location of the center of the scaled
cylinder, (2) the 'left' x radius and (3) the 'up' y radius to get
the cylinder tangeant to the boxes. I don't think that rotating the
cylinder around the z-axis is necessary.

I tried to solve the problem with the following equations:

An ellipse has to passes through point A(Xa, Ya) and
B(Xb, Yb). Its axis are parallel to the main axis. The
orientation of the tangent in A and B are given: Ta, Tb

P0(X0, Y0) the 'center' of the ellipse (center of a
scaled circle)
As I use a scaled circle, I use semi-axis of R and
s*R

So we have for each point

(Xa-X0)^2+(Ya-Y0)^2/L^2=R^2

this is equivalent to

Xa = X0 + R cos(Aa)
Ya = Y0 + L R sin(Aa)

Aa is the parametric angle A for point A
(note that this is in on way the real angle
from OX to OA)

And the tangent:
Xa'= -R sin(Aa)
Ya'= L R cos(Aa)

=> Ta = Ya' / Xa' =  -L / tan(Aa)

...same equations for point B...

So we have a system of 6 equations, with 6 unknowns:
X0, Y0, R, L, Aa, Ab.
Aa an Ab are of no interrest but can be necessary
to solve the system.

I tried but was unable to get an answer - it was to
complicated for me, and I can no longer access
a copy of Mathematica, so...


Any help welcome,

Thank you very much,

Philippe


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Help! Can anyone figure this math?
Date: 28 Aug 1998 18:41:46
Message: <35E7243F.B7CDFF19@Ragingbull.com>
You are working too hard.  The scaled cylinder is not an ellipse. It is
merely a cylinder with a scaled axis.  There are several differences,
not the least of being the definition.  A cylinder is defined easily by
x = rcos(theta) and y = rsin(theta) (or vis versa) So try working with 
x = rcos(theta)
y = Rsin(thete) 

so the x position 30 degrees around the cylinder would be r*sqrt(3)/2
and the y position would be R*0.5 if you move the cylinder, simply add
the displacement to the values above.  

Philippe Debar wrote:
> 
> I was totally unable to solve this problem for a pov scene.
> I found a workaround, but I am not totally satisfied with it.
> 
> The problem is to get a smooth joint between differently
> oriented surfaces. In this case, two boxes rotated around
> the z-axis. I wanted to use a scaled cylinder (to get an
> ellipse). What are (1) the location of the center of the scaled
> cylinder, (2) the 'left' x radius and (3) the 'up' y radius to get
> the cylinder tangeant to the boxes. I don't think that rotating the
> cylinder around the z-axis is necessary.
> 
> I tried to solve the problem with the following equations:
> 
> An ellipse has to passes through point A(Xa, Ya) and
> B(Xb, Yb). Its axis are parallel to the main axis. The
> orientation of the tangent in A and B are given: Ta, Tb
> 
> P0(X0, Y0) the 'center' of the ellipse (center of a
> scaled circle)
> As I use a scaled circle, I use semi-axis of R and
> s*R
> 
> So we have for each point
> 
> (Xa-X0)^2+(Ya-Y0)^2/L^2=R^2
> 
> this is equivalent to
> 
> Xa = X0 + R cos(Aa)
> Ya = Y0 + L R sin(Aa)
> 
> Aa is the parametric angle A for point A
> (note that this is in on way the real angle
> from OX to OA)
> 
> And the tangent:
> Xa'= -R sin(Aa)
> Ya'= L R cos(Aa)
> 
> => Ta = Ya' / Xa' =  -L / tan(Aa)
> 
> ...same equations for point B...
> 
> So we have a system of 6 equations, with 6 unknowns:
> X0, Y0, R, L, Aa, Ab.
> Aa an Ab are of no interrest but can be necessary
> to solve the system.
> 
> I tried but was unable to get an answer - it was to
> complicated for me, and I can no longer access
> a copy of Mathematica, so...
> 
> Any help welcome,
> 
> Thank you very much,
> 
> Philippe


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Help! Can anyone figure this math?
Date: 28 Aug 1998 18:43:03
Message: <35E7248D.1E1DEF8F@Ragingbull.com>
I actually defined a circle above, but you merely have to extrude my
formula on the third axis to create a cylinder... just wanted to
clarify, it doesn't change the validity of the formulii

Stephen Lavedas wrote:
> 
> You are working too hard.  The scaled cylinder is not an ellipse. It is
> merely a cylinder with a scaled axis.  There are several differences,
> not the least of being the definition.  A cylinder is defined easily by
> x = rcos(theta) and y = rsin(theta) (or vis versa) So try working with
> x = rcos(theta)
> y = Rsin(thete)
> 
> so the x position 30 degrees around the cylinder would be r*sqrt(3)/2
> and the y position would be R*0.5 if you move the cylinder, simply add
> the displacement to the values above.
>


Post a reply to this message

From: Philippe Debar
Subject: Re: Help! Can anyone figure this math?
Date: 29 Aug 1998 13:34:35
Message: <35e82d9b.0@news.povray.org>
Hi Stephen (and everybody else reading this)

I am sorry, but I do not understand your answer. Well,
I think I understand it, but I do not see how it can solve
my problem.

I don't see the difference between
(a) working with semi-axis ('radii') of r and R
and
(b) semi-axis of R and L*R

Isn't a scaled circle (cylinder) an ellipse ?
circle at origin:
  x=R*cos(theta)
  y=R*sin(theta)

scale <1,L,*> =>
  x=1*R*cos(theta)=R*cos(theta)
  y=L*R*cos(theta)

translate <x0,y0,*>
  x=x0+R*cos(theta)
  y=y0+L*R*cos(theta)

- this is an ellipse


Is this wrong?

(See also my next post which explain my
problem further)


Thanks


Philippe


Post a reply to this message

From: Philippe Debar
Subject: Re: Help! Can anyone figure this math?
Date: 29 Aug 1998 13:38:17
Message: <35e82e79.0@news.povray.org>
Hi everybody!

I seem to have difficulties to explain my problem
clearly. Here's another try:

With ascii geometry, in a plane:


-------------+
              \
Volume  A      \
                \
-----------------+   <--- point A

          Find the scaled cylinder that will
          smoothly join these two surfaces.

--------------+        <--- point B
             /
  Volume B  /
           /
----------+


Why a scaled cylinder? Because I can the use the solution
to smoothly join two cones with a scaled torus.

The problem is to find the center and the two semi-axis
of an ellipse whose axis are parallel to the world axis,
that is tangent with two given half lines on their end
point. That is:



         \
          \      half line a
           \
            \
             +   <--- end point A


          Find the ellipse that will
          smoothly join these two half lines.


          +        <--- end point B
         /
        /
       /
      /



Thank you for your time,

Sincerely,


Philippe


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Help! Can anyone figure this math?
Date: 29 Aug 1998 17:10:32
Message: <35E85E76.CC135024@Ragingbull.com>
A ellipse has the formula (in two dimensions) x^2/a^2 + y^2/b^2 = c^2
where the major axis is a or b depending on which is larger.  In an
ellipse, any ray drawn from a foci and bounced off a wall will terminate
in the other foci.  There are actually two foci instead of one radius. 
Anyhow...question for you... where is the center of the torus you use in
relation to the boxes?  I ask this, because from the image, I think
rotation of the cylinder is required.  However if you send me some
source I could be more helpful... (feel free to email it to me)

Steve



Philippe Debar wrote:
> 
> Hi Stephen (and everybody else reading this)
> 
> I am sorry, but I do not understand your answer. Well,
> I think I understand it, but I do not see how it can solve
> my problem.
> 
> I don't see the difference between
> (a) working with semi-axis ('radii') of r and R
> and
> (b) semi-axis of R and L*R
> 
> Isn't a scaled circle (cylinder) an ellipse ?
> circle at origin:
>   x=R*cos(theta)
>   y=R*sin(theta)
> 
> scale <1,L,*> =>
>   x=1*R*cos(theta)=R*cos(theta)
>   y=L*R*cos(theta)
> 
> translate <x0,y0,*>
>   x=x0+R*cos(theta)
>   y=y0+L*R*cos(theta)
> 
> - this is an ellipse
> 
> Is this wrong?
> 
> (See also my next post which explain my
> problem further)
> 
> Thanks
> 
> Philippe


Post a reply to this message

From: Peter Popov
Subject: Re: Help! Can anyone figure this math?
Date: 30 Aug 1998 02:52:44
Message: <35e8e8ac.0@news.povray.org>
Well, seems to me eveeryone's working on the trigonometric solution...
here's a cheep 'n' cheesy one. You'll need two points on each surface,
though (and their order must match)

#declare A1=<Ax,Ay,Az> // point A1
#declare B1=<Bx,By,Bz>  // point B1
#declare A2=<Ax,Ay,Az> // point A2
#declare B2=<Bx,By,Bz>  // point B2
#declare tangentA=<tAx,tAy,tAz> // tangent at A
#declare tangentB=<tBx,tBy,tBz>  // tangent at B

// The tangents of the surfaces have to point in the direction of the
joining surface.
// Anyway that's easy to correct with a tangentA_direction (+1 or -1) etc.

#declare weightA = 1  // how strongly the tangent of A "attracts" the
tangent of the joining surface
#declare weightB = 1  // same as above

#declare addToA = weightA*tangentA
#declare addToB = weightB*tangentB

bicubic_patch
{ type 1
   flatness 0
   u_steps 4
   v_steps 4
    A1, (A1+A2)/3, (A1+A2)*2/3, A2,
    A1, (A1+A2)/3+addToA, (A1+A2)*2/3+addToA, A2+addToA,
    B1, (B1+B2)/3+addToB, (B1+B2)*2/3+addToB, A2+addToB,
    B1, (B1+B2)/3, (B1+B2)*2/3, B2,
}

I haven't tested this, but it looks OK to me. Of course, you can't use it in
CGS. If you want to do intersections and/or differences, try using prisms
instead. Well, they extrude along y, so you'll have be careful. Also, when
using a cubic_spline in prisms keep in mind it starts from the second point
and ends at the second-to-last, so the tangents should point opposite to
what is used above, plus you'll have to interchange points 1&2 and points
3&4 from the above example.

Hope this helps.

--Peter

pet### [at] usanet



Philippe Debar wrote in message <35e71797.0@news.povray.org>...
>I was totally unable to solve this problem for a pov scene.
>I found a workaround, but I am not totally satisfied with it.
>
>The problem is to get a smooth joint between differently
>oriented surfaces. In this case, two boxes rotated around
>the z-axis. I wanted to use a scaled cylinder (to get an
>ellipse). What are (1) the location of the center of the scaled
>cylinder, (2) the 'left' x radius and (3) the 'up' y radius to get
>the cylinder tangeant to the boxes. I don't think that rotating the
>cylinder around the z-axis is necessary.
>
>I tried to solve the problem with the following equations:
>
>An ellipse has to passes through point A(Xa, Ya) and
>B(Xb, Yb). Its axis are parallel to the main axis. The
>orientation of the tangent in A and B are given: Ta, Tb
>
>P0(X0, Y0) the 'center' of the ellipse (center of a
>scaled circle)
>As I use a scaled circle, I use semi-axis of R and
>s*R
>
>So we have for each point
>
>(Xa-X0)^2+(Ya-Y0)^2/L^2=R^2
>
>this is equivalent to
>
>Xa = X0 + R cos(Aa)
>Ya = Y0 + L R sin(Aa)
>
>Aa is the parametric angle A for point A
>(note that this is in on way the real angle
>from OX to OA)
>
>And the tangent:
>Xa'= -R sin(Aa)
>Ya'= L R cos(Aa)
>
>=> Ta = Ya' / Xa' =  -L / tan(Aa)
>
>...same equations for point B...
>
>So we have a system of 6 equations, with 6 unknowns:
>X0, Y0, R, L, Aa, Ab.
>Aa an Ab are of no interrest but can be necessary
>to solve the system.
>
>I tried but was unable to get an answer - it was to
>complicated for me, and I can no longer access
>a copy of Mathematica, so...
>
>
>Any help welcome,
>
>Thank you very much,
>
>Philippe
>
>


Post a reply to this message

From: Philippe Debar
Subject: Re: Help! Can anyone figure this math?
Date: 30 Aug 1998 16:17:36
Message: <35e9a550.0@news.povray.org>
Hello math fans...

I still seem to have difficulties making myself undersood.
A too long time since school and the lack of proper english
mathematic vocabulary aren't helping ;-)

So, here we go for another try:

Stephen Lavedas wrote in message <35E85E76.CC135024@Ragingbull.com>...
>A ellipse has the formula (in two dimensions) x^2/a^2 + y^2/b^2 = c^2
>where the major axis is a or b depending on which is larger.

...hmm, let me see... it seems that... hmm... yes... ...
er... I'll need that book... thank you... and, er... that one too...

x^2/a^2 + y^2/b^2 = c^2 surely is an ellipse... but of axis 2*a*c and
2*b*c. You surely meant x^2/a^2 + y^2/b^2 = 1.

This ellispse has its center (the intersection of the two axis) at <0,0> and
two focii (I do not know their coordinates, but this doesn't matter here).

x^2/a^2 + y^2/b^2 = 1 is the cartesian equation (in rectangular
coordinates) of the ellipse. The pair of trigonometric equations
I tried was the parametric equation (in rectangular coordinates)
and is equivalent to the cartesian one (they describe the same
shape).

... or so I believe, but I can of course be wrong.

>Anyhow...question for you... where is the center of the torus you use in
>relation to the boxes?

That's a part of what I am trying to solve. Given: (in plane) two points
their tangents; unknown an ellipse (center and two half-axis). The
system of six equations for six unknowns led me to believe that it can
be done without the rotation of the cylinder. But maybe the system is
unsolvable this way and you really need the rotation. My purpose
would be defeated if this was the case.

>However if you send me some source I could be more helpful...
>(feel free to email it to me)

I can't: I am writing macros to do linear mouldings as well as collumns
relief, so I am after a general solution. But if you want, I can post or
email what I have already done. The file isn't very long, but is written
in a kind of franglais, with architectural terms my dictionnary can't
translate.



Thank you again for your help,

Thruthfully,


Philippe


Post a reply to this message

From: Philippe Debar
Subject: Re: Help! Can anyone figure this math?
Date: 30 Aug 1998 16:27:39
Message: <35e9a7ab.0@news.povray.org>
Greetings!

Peter Popov wrote in message <35e8e8ac.0@news.povray.org>...
>Well, seems to me eveeryone's working on the trigonometric solution...
>here's a cheep 'n' cheesy one. You'll need two points on each surface,
>....<

Thanks, Peter, for your solution. You've guessed: I do need CSG operations.
And I'd really like to solve my problem with a cylinder (or, as the case may
be, a torus between cones). That's a purity and code elegance (and perhaps
stupid) affair.


But I printed your answer and will keep it handy.


Thank you again,

Sincerely,

Philippe


Post a reply to this message

From: Peter Popov
Subject: Re: Help! Can anyone figure this math?
Date: 31 Aug 1998 02:46:50
Message: <35ea38ca.0@news.povray.org>
Hi Philippe!

Philippe Debar wrote in message <35e9a7ab.0@news.povray.org>...
>Greetings!
>
>Peter Popov wrote in message <35e8e8ac.0@news.povray.org>...
>>Well, seems to me eveeryone's working on the trigonometric solution...
>>here's a cheep 'n' cheesy one. You'll need two points on each surface,
>>....<
>
>Thanks, Peter, for your solution. You've guessed: I do need CSG operations.
>And I'd really like to solve my problem with a cylinder (or, as the case
may
>be, a torus between cones). That's a purity and code elegance (and perhaps
>stupid) affair.
>

Code elegance is a very important thing, especially when it comes to IRTC or
patching POV :)

>
>But I printed your answer and will keep it handy.

I'm afraid there was a typo in what I posted here... Dan Conelly pointed in
out to me in an e-mail. Here we go:

<clip>

    A1, (A1+A2)/3, (A1+A2)*2/3, A2,
    A1+addToA, (A1+A2)/3+addToA, (A1+A2)*2/3+addToA, A2+addToA,
    B1+addToB, (B1+B2)/3+addToB, (B1+B2)*2/3+addToB, A2+addToB,
    B1, (B1+B2)/3, (B1+B2)*2/3, B2,

<clip>

Anyway, if CSG is what you need I still think a prism is the easiest choice.
Here's an example:

I still assume you want to join two straight edges; however, as opposed to
the
bicubic_patch example, they *must* be parallel. I will assume they are
vertical
(to make my prism easier) but you can transform the prism later. Also, the
tangents must be horizontal. Lastly, here +x is right, +y is up, +z is
inside

#declare A1=<Ax,Ay,Az> // point A1, vertex 1 of edge A
#declare B1=<Bx,By,Bz>  // point B1, vertex 1 of edge B
#declare A2=<Ax,Ay,Az> // point A2, vertex 2 of edge B
#declare B2=<Bx,By,Bz>  // point B2, vertex 2 of edge B
#declare tangentA=<tAx,tAy,tAz> // tangent at A,
#declare tangentB=<tBx,tBy,tBz>  // tangent at B

// The tangents of the surfaces have to point opposite to the direction
// of the joining surface.

#declare weightA = 1  // how strongly the tangent of A "attracts" the
tangent of the joining surface
#declare weightB = 1  // same as above
#declare addToA = weightA*tangentA
#declare addToB = weightB*tangentB
prism
{
  cubic_spline
  linear_sweep
  A1.y, A2.y, 4,
  A1+addToA, A1, B1, B1+addToB
}

This should generate a prism from edge A1-A2 to edge B1-B2. I am not sure
how you should close this prism, though

>Thank you again,
>
>Sincerely,
>
>Philippe
>

Glad to help.

Regards,

Peter

P.S. Sorry, I'm not very much into elegant coding


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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