POV-Ray : Newsgroups : povray.general : Determining rotation Server Time
4 Nov 2024 21:22:06 EST (-0500)
  Determining rotation (Message 1 to 7 of 7)  
From: Tail Kinker
Subject: Determining rotation
Date: 10 May 2008 19:55:41
Message: <482635fd@news.povray.org>
I am working with limbs still.  Given a point A, a given distance (r) 
from the origin, how would I determine the angles to rotate an object at 
<0, r, 0> to match A?  I've beaten my head against this one for some 
weeks now, and my math skills are not up to the task.


Post a reply to this message

From: Warp
Subject: Re: Determining rotation
Date: 10 May 2008 20:02:51
Message: <482637ab@news.povray.org>
Tail Kinker <the### [at] gmailcom> wrote:
> I am working with limbs still.  Given a point A, a given distance (r) 
> from the origin, how would I determine the angles to rotate an object at 
> <0, r, 0> to match A?  I've beaten my head against this one for some 
> weeks now, and my math skills are not up to the task.

  No need to do the math when others have already done it for you:

http://povray.org/documentation/view/3.6.1/488/

-- 
                                                          - Warp


Post a reply to this message

From: Chris B
Subject: Re: Determining rotation
Date: 11 May 2008 05:40:56
Message: <4826bf28$1@news.povray.org>
"Tail Kinker" <the### [at] gmailcom> wrote in message 
news:482635fd@news.povray.org...
>I am working with limbs still.  Given a point A, a given distance (r) from 
>the origin, how would I determine the angles to rotate an object at <0, r, 
>0> to match A?  I've beaten my head against this one for some weeks now, 
>and my math skills are not up to the task.

This can get quite complicated, depending on precisely what you want to do. 
Particularly when posing limbs where you may need to work in a sequence 
that's different from the conventional X-Y-Z rotation sequence.

If you aren't interested in the orientation of the object around its own 
axis (you usually are with limbs), you can get from <0,r,0> to anywhere with 
one X rotation followed by one Y rotation (anywhere where vlength(A)=r).

You can work out the angles, one at a time, by taking the point that you get 
by projecting point A onto the YZ-plane (project a line through A and 
through the YZ-plane at right angles). This point will be at <0,A.y,A.z>. 
You can now use trigonometry to work out the two angles you're interested 
in, or you can use the VAngleD() function from math.inc (you'll obviously 
need to take care over angles in the different quadrants).

If you are interested in the final orientation of the limb (which you 
probably are) then getting a single X-Y-Z rotation gets quite a bit more 
complicated. A simpler alternative is to apply the reverse rotations you get 
from the previous calculation to an orientation vector (a normal to Vector 
A) to bring it back onto the XZ-plane. You can then use VAngleD() to work 
out a Y rotation that can be applied to the object before you apply the X-Y 
rotations from the previous calculation to the limb object. By doing this 
you end up with a Y-X-Y rotation sequence, rather than an X-Y-Z rotation 
sequence, so you'll need to apply two POV-Ray rotation statements rather 
than one.

Hope that helps unlock the particular bits of grey matter that beating your 
head didn't :-)

Regards,
Chris B.


Post a reply to this message

From: Tail Kinker
Subject: Re: Determining rotation
Date: 11 May 2008 06:07:26
Message: <4826c55e@news.povray.org>
Warp wrote:

>   No need to do the math when others have already done it for you:
> 
> http://povray.org/documentation/view/3.6.1/488/

Perhaps I am blind, or stupid, but I cannot see how any of these 
functions would assist in this problem. Could you please clarify?


Post a reply to this message

From: Warp
Subject: Re: Determining rotation
Date: 11 May 2008 06:38:32
Message: <4826cca8@news.povray.org>
Tail Kinker <the### [at] gmailcom> wrote:
> Warp wrote:

> >   No need to do the math when others have already done it for you:
> > 
> > http://povray.org/documentation/view/3.6.1/488/

> Perhaps I am blind, or stupid, but I cannot see how any of these 
> functions would assist in this problem. Could you please clarify?

  You asked how to rotate a vector <0, r, 0> so that it ends up
pointing at the same direction as a vector A. That's precisely what
the Point_At_Trans() macro does.

  (Or, more precisely, the Point_At_Trans() macro creates a transformation
which you can use in an object or to modify a vector using vtransform).

-- 
                                                          - Warp


Post a reply to this message

From: Chris B
Subject: Re: Determining rotation
Date: 11 May 2008 08:35:07
Message: <4826e7fb@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote in message 
news:4826bf28$1@news.povray.org...
> ... snip ...
> You can work out the angles, one at a time, by taking the point that you 
> get by projecting point A onto the YZ-plane (project a line through A and 
> through the YZ-plane at right angles). This point will be at <0,A.y,A.z>. 
> You can now use trigonometry to work out the two angles you're interested 
> in, or you can use the VAngleD() function from math.inc (you'll obviously 
> need to take care over angles in the different quadrants).

Sorry. I got this a bit wrong.
To get the 'Y' rotation you need to drop point A down onto the XZ-plane. The 
'Y' rotation is therefore VAngleD(z,<A.x,0,A.z>). To get the 'X' rotation 
you need to rotate point A back onto the YZ-plane so that it lies in +Z. To 
do this, use vrotate() with point A and the negative of the Y-rotation you 
just calculated. This gives you a point B on the YZ-plane that you can use 
with VAngleD(y,B) to retrieve the first rotation angle.

> ... snip ...

Regards,
Chris B.


Post a reply to this message

From: Tail Kinker
Subject: Re: Determining rotation
Date: 11 May 2008 16:59:22
Message: <48275e2a@news.povray.org>
Warp wrote:

>   You asked how to rotate a vector <0, r, 0> so that it ends up
> pointing at the same direction as a vector A. That's precisely what
> the Point_At_Trans() macro does.
> 
>   (Or, more precisely, the Point_At_Trans() macro creates a transformation
> which you can use in an object or to modify a vector using vtransform).
> 
Okay, so I'm stupid.  :)  Thanks for the assist.


Post a reply to this message

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