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.