center of triangle

The code snippet below is what I have implemented to try to get surface normals for my model so that I can tell the difference between tops and bottoms of my elements.

— calculating normals

v1.sub(pointA, pointB);
v2.sub(pointA, pointC);

vec.cross(v1, v2);
vec.normalize();


But as I understand it, a surface normal is a vector from the centroid of the face that runs out in a 90 degree angle. Has a start and an end point.

But I need two points (a start and an end) for my normals. So I think what I need to do is find the centroid of my triangle, then add the ‘vec’ vector (above) to this centroid so that I have starting and ending points for my surface normal and then I can plot them to which way the direction is for my surface elements.

But I don’t know how to find the center of a triangle. Does that sound right? If so, does anyone know of any code/formula examples (w/o too much math) that would help me find the centroid of a triangle.

just adding the 3 vertex coordinate and divide by 3…

It’s a well know formula:
to find the center of a triangle (gravity center in this case), we used the relathionship: (ABC is the triangle, G, the center, and GX the vector from G to X)
GA+GB+GC=0

GA = [G] - [A]
so:
3[G] = [A] + [B] +[C];

and bingo!

glNormal() does not draw the normal. It specifies the vertex normals used in the lighting calculations.