I have a rectangle which is created by 2 triangles and it is in x-z plane, and i have object on it. Now, the normals of two triangles (face normals) are y axis i.e. (0,1,0). I want to display normals of two triangles for which i need two points to draw a line to show normal. Intuitively if i take center of a triangle as one and (0,1,0) as second point of a normal then both of the normals will converge to single point. I dont think it is correct as the normal should be exactly perpendicular to the surface. We can do a trick and take one point as a center and other by increasing y coordinate keeping x and z same, but what if we have curved surface and not a plane board? What about the cylinder made of triangles? How could we display normals as a lines of cylinder? I guess i am missing very basic concept here, please help me to understand it and tell me how to calculate the two points of normal.
Usually you already have normals for all three vertecies that make a tri. In that case you average the position of the vertecies as the first point and add the average of all 3 normals to get the second point.
(v0 v1 and v2 are supposed to be the vertecies that make up the triangle) If you don't already have normals and you want to calculate them then you just calculate the cross product of
perpendicular = v0v1 x v0v2 and then normalize the result (divide by length). The order is important. v0 is the first vertex, v1 the second and v2 the third.
v0v1 = v1-v0 and v0v2 =
v2-v0. Start point is as was before
start = (v0+v1+v2)/3.0 and the end is then
end = start+ (perpendicular/length(perpendicular))
Also, depending on your model size the length of 1 might be too small or too huge, in that case just use a scaling factor.
This is really more of a comment but it's a little too long so I'm posting it as an answer