# Thread: Is it possible to find the direction a tri is facing?

1. ## Is it possible to find the direction a tri is facing?

I'm writing some code and I only want it to operate on tri-s facing up. So if they have an angle off the Z axis of more than 90 degrees then they're ignored. Is there any easy way to check this?

2. It's called the Face Normal...

Normal = Normalize(cross(vert1-vert0, vert2-vert0))
where vert0, vert1 and vert2 are the positions of the triangle vertices.

If in the end, the Z component of the Normal is positive, then the triangle is facing up... more exactly, since the Normal is normalized, the Z component corresponds to the cosine of the angle between the Normal and the Z axis; 1 means the normal and the Z axis are the same, 0 means they are perpendicular, and -1 means the normal is pointing to -Z.

3. Thanks! That's really helpful. Does that return a vector? I've never used those before.

4. yes, the cross product between two vectors (in this case two edges of the triangle,) returns a vector perpendicular to both vectors with a length equal to the product of the lenght of both vectors and the sine of the angle between them. (but since we are normalizing the cross product, the final lenght is just equal to 1)

#### Posting Permissions

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