# Calculating Surface Normal

## Recommended Posts

X Abstract X    109
I'm trying to calculate the surface normal for a simple triangle but, embarassingly enough I can't seem to get it right. Thanks for looking.
vertex1 = (100, 100, 0)
vertex2 = (150, 200, 0)
vertex3 = (200, 100, 0)

vectorA = vertex2 - vertex1
= (50, 100, 0)

vectorB = vertex3 - vertex1
= (100, 0, 0)

normal.x = A.y * B.z - A.z * B.y
= 100 * 0 - 0 * 0
= 0
normal.y = A.z * B.x - A.x * B.z
= 0 * 100 - 50 * 0
= 0
normal.z = A.x * B.y - A.y * B.x
= 50 * 0 - 0 * 50
= 0

normal = (0, 0, 0)



##### Share on other sites
alvaro    21266
Take two sides of the triangle as vectors (say, vertex1-vertex2 and vertex1-vertex3), compute the cross product and normalize the result. If you don't like the sign of the normal vector you get, reverse the order of the two sides.

##### Share on other sites
szecs    2990
Yes, copying numbers is a hard task :P
Check the values again.

##### Share on other sites
GregMichael    135
A.y = 100
B.x = 100

Normal.z = A.x * B.y - A.y * B.x
= 50 * 0 - 100 * 100
= -10000

normal = (0, 0, -10000)

(i think :)

Edit...ooops got sign wrong :)

##### Share on other sites
X Abstract X    109
Thanks everyone. Apparently I have trouble copying numbers lol.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account