# Difference between revisions of "Calculating a Surface Normal"

Jump to navigation
Jump to search

m (Add Category Algorithm) |
m |
||

Line 1: | Line 1: | ||

A surface normal for a triangle can be calculated by taking the vector cross product of two edges of that triangle. The order of the vertices used in the calculation will affect the direction of the normal (in or out of the face w.r.t. winding). | A surface normal for a triangle can be calculated by taking the vector cross product of two edges of that triangle. The order of the vertices used in the calculation will affect the direction of the normal (in or out of the face w.r.t. winding). | ||

− | So for a triangle p1, p2, p3, if the vector U = p2 - p1 and the vector V = p3 - p1 then the normal N = U X V and can be calculated by: | + | So for a triangle p1, p2, p3, if the vector <math>U=p2-p1</math> and the vector V = p3 - p1 then the normal N = U X V and can be calculated by: |

Nx = UyVz - UzVy | Nx = UyVz - UzVy |

## Revision as of 12:21, 30 April 2006

A surface normal for a triangle can be calculated by taking the vector cross product of two edges of that triangle. The order of the vertices used in the calculation will affect the direction of the normal (in or out of the face w.r.t. winding).

So for a triangle p1, p2, p3, if the vector and the vector V = p3 - p1 then the normal N = U X V and can be calculated by:

Nx = UyVz - UzVy

Ny = UzVx - UxVz

Nz = UxVy - UyVx