# Normals?

Somebody help me please how to compute normal for triangle from 3 vertices?

By the way XBCT and Flash - thanx.

Compute the cross product of the three vertices and don’t forget to normalize it.
Then all you have to do is glNormal(the result of the cross product).
If you have no idea how to do this mail me I can send you two small self explanatory functions.

BTW any 3d artist with free time ?

hey elmargo…
can you send those function for me ???

guivieira@brfree.com.br

consider having 3 vertices, p1, p2, p3.
now consider having 2 vectors:

A = (ax, ay, az) = p2-p1
B = (bx, by, bz) = p3-p1

so the A vectors coordinates (ax,ay,az) are
created from substracting coordinates of p1 from p2 (treated as vectors), resp.:

ax = p2x-p1x
ay = p2y-p1y
az = p2z-p1z

the same for vector B.

the normal of the triangle is then vector N, where:

N = AxB = (aybz-azby,azbx-axbz,ax*by-aybx)

the vector -N = (-nx,-ny,-nz) is also perpendricular to the triangle, so it is also a normal… it holds that -N = BxA, and so AxB = -BxA.

so as you see, the direction of the normal depends on the order in which you take the vertices (the orientation of the normal is sometime used to determine whether the triangle is backfacing or not… in 3ds the vertices within each face are stored in an order which allows to utilize this).
(the vertices are saved in counter clockwise order, if i remember right)

Isn’t this supposed to be advanced?

good question. it seems to me like the most of the questions here have nothing or very little to do with opengl, and to see questions like this in advanced corner… it should get moderated here.