# Vertex Normals

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

## Recommended Posts

Could you please give me the detailed calculations of the normal of a surface formed by vertices below? I calculated them myself but when I use them in my OpenGL program they give me wrong results. I just want to compare my calculations and make sure that I’m doing them right. P0 = (-1.0, 0.0, 1.0) P1 = ( 0.0, 1.0, 0.0) P2 = (-1.0, 0.0, -1.0)

##### Share on other sites
N = (P2 - P0 ) X ( P1 - P0 )
N = [ 2, -2, 0 ], and normalized: N = [ sqrt(2)/2, -sqrt(2)/2, 0 ]

You may have to adjust depending on which side is the front (as determined by the order of the vertexes).

##### Share on other sites
That’s the result I got but according to a sample app the normal is:

N = [-2, 2, 0], normalized N = [-0.707, 0.707, 0.0]

Which doesn't make sense and it’s driving me insane!

##### Share on other sites
Quote:
 Original post by hungryhippo5000That’s the result I got but according to a sample app the normal is:N = [-2, 2, 0], normalized N = [-0.707, 0.707, 0.0]Which doesn't make sense and it’s driving me insane!

Remember that AxB = -(BxA). The difference is probably due to the order in which the vertexes are specified -- clockwise vs. counter-clockwise. That is how front and back are usually determined.

##### Share on other sites
This is a typical conflict of 3d coordinates' system handedness. Imagine aligning your right thumb with the direction from P0 to P1, and your right index finger with the direction from P0 to P2. A right handed system would interpret their cross product, as pointing to the direction of your right middle finger (when you stretch it out perpendicular to your palm). A left handed system would yield the exact opposite direction.

As JohnBolton said, this has immediate impact on the 3d api's ability to determine the visible side of a triangle. If you port geometry created in a left-handed system, into a right-handed one, (or vice-versa) you'll have to switch the declaration of vertices in all faces, as such:
1. change vertex order from {v0,v1,v2} into {v0,v2,v1}
2. Multiply your view matrix with the reflection matrix
    [ 1  0  0  0 ]R = [ 0  1  0  0 ]    [ 0  0 -1  0 ]    [ 0  0  0  1 ]

Let V be the view matrix. If you use column-major format use as a view matrix the product V*R, else R*V.

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011722
• ### Who's Online (See full list)

There are no registered users currently online

×