Rotating to position...

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 ?

thanks in advance,
[],

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.

Thanks,
it worked,

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?

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).