Jump to content
• Advertisement

# Calculating Surface Normal

This topic is 2986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

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 this post

##### Share on other sites
Advertisement
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 this post

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

#### Share this post

##### Share on other sites
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 this post

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

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Now

• 23
• 10
• 19
• 15
• 14
• Advertisement
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!