|
|
In article <37ee313a@news.povray.org> , "TonyB"
<ben### [at] panamaphoenixnet> wrote:
> Given 2 points in 2D* or 3D space, A and B, how can I make an object rotate
> to line itself up to the line AB?
You just want the rotation, so you need to find them one after each other.
In the following I will assume the left-handed coordinate system. I will
call your vector AB = V .
First, determine the rotation between needed to the vector will be in the
xz-plane. Doing so is easy:
r = vlength(V);
so you get
sin a = V.y / r
your first angle is
a = asin(V.y / r) // Remember: POV-Ray returns asin in radians!
Next you want the angle of the newly fromed vector (or any vector with the
same direction) with the x-axis
M = <V.x, 0, V.z>
r = vlength(M);
g = asin(M.z / r)
Now you have to angles, I guess you can figure out the rest yourself :-)
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
|