PDA

View Full Version : Rotating to position...

ricfow
02-04-2004, 03:11 AM
Hi,
I have a triangle with normal vector (nx,ny,nz),

i want to rotate this triangle such that
the normal vector be aligned with (0,1,0).
i.e., after the rotation, all the vertices
of the triangle will have the same
y coordinate.

how can i do this ?

[],

Coconut
02-04-2004, 08:15 AM
It may not be simpliest, but here you go:
1) Find the angle, a, between (nx, ny, nz) and (0, 1, 0) using dot product,
2) If a is zero, then stops
3) if a is 180 degrees, then rotate the triangle by 180 degrees.
4) Else, find the cross product of (nx, ny, nz) and (0, 1, 0)
5) Rotate triangle around the cross product by a.

ricfow
02-08-2004, 03:30 PM
Thanks,
it worked,

Freelancer
02-19-2004, 01:00 AM
By the way, if I have a "(0,1,0)-normaled" triangle, and I want to face it to (nx, ny, nz)-normal, what should I do?

Coconut
02-19-2004, 04:19 AM
Originally posted by Freelancer:
By the way, if I have a "(0,1,0)-normaled" triangle, and I want to face it to (nx, ny, nz)-normal, what should I do?

Same thing except (nx, ny, nz) becomes (0, 1, 0) and (0, 1, 0) becomes (nx, ny, nz).