# The Industry's Foundation for High Performance Graphics

1. ## 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 ?

[],

2. ## Re: Rotating to position...

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,

4. ## Re: Rotating to position...

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?

5. ## Re: Rotating to position...

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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•