Triangle Normal Calculation

hello,

i am looking for a little help with the normals

my 3 vertex of the triangle should get the
same normal but i dont know how to calculate the
normal vector of this?

tri_x[0],tri_y[0],tri_z[0]
tri_x[1],tri_y[1],tri_z[1]
tri_x[2],tri_y[2],tri_z[2]

nor_x=?,nor_y=?,nor_z=?

thanks for any help

To calculate the normal, take the cross product of the two vectors formed by v1 = (tri_x[1]-tri_x[0];tri_y[1]-tri_y[0];tri_z[1]-tri_z[0]) and v2 = (tri_x[2]-tri_x[0];tri_y[2]-tri_y[0];tri_z[2]-tri_z[0]). Don’t forget that v1^v2 = -v2^v1.

Wow! I think there is an epidemic about normals computation issue this week, perhaps the premices of the april, 1st virus… :slight_smile: Seriously, an article about this on the opengl wiki might be helpful.

thank you very much for the help with the formula

I think there is an epidemic about normals computation issue this week

hehe, i wonder about opengl and directx why they use
normal vectors with each vertex ?
why not one normal vector for each triangle.

opengl make all the stuff with light,cullface etc…
why does it not automatic generate the normals of triangle surfaces,life could much more easyer;)

greetings :slight_smile:

if your model is hard-edged, like box, one normal per triangle is OK;

if your model is curved, like sphere, the normals must represent the actual ones on the curved surface rather than the ones on the approximate polyhedron model.

sometimes both kinds of normals even exist on the same model.

in order to make the result as you expect, OpenGL just leave the work to you.

And for the sake of completeness, most meshes not have only one normal per vertex but several, especially at hard edges. This follows what ephtracy said, vertex normal depend on the triangle it belongs to, that is why it could have several normals on hard edges.
I advise you to play withy normals in 3d modelers like 3dsmax, blender, maya and friends just to understand this concept.