PDA

View Full Version : Calculating Normal vectors

chuks
08-05-2003, 08:03 AM
Hi,
part of my project involves using opengl. I will like to know how to calculate normal vectors (for glNormal3f) for a large set of scanned object. assumming the data is something like this.....

glBegin(GL_TRIANGLES);
glNormal3f ();
glVertex3f(7.4350, -2.47203, -45.1869);
glVertex3f(71.6133, 6.12588, -53.2960);
glVertex3f( 50.12, 10.45, 23.00);
glNormal3f ();
glVertex3f(74.4350, -2.47203, -45.1869);
glVertex3f( 77.6763, -2.29052,-38.1057);
glVertex3f( 82.0971, -7.86762, -36.3902);
glNormal3f ();
glVertex3f( 74.4350, -2.47203, -45.1869);
glVertex3f( 71.6133, 6.12588, -53.2960);
glVertex3f( 67.6907, -1.83262, -61.1861);
glNormal3f ();
glVertex3f( 74.4350, -2.47203, -45.1869);
........etc
any contribution will be appreciated.
chuks

08-05-2003, 09:29 AM
you have 3 vertices with a x, y and z coordinate. this vertices are 3-dimensional vectors. Use the Crossproduct and you'll get a normal vec

(v3-v1)x(v2-v1)

mikael_aronsson
08-05-2003, 09:31 AM
Hi !

Have a look at:
http://www.ime.usp.br/~massaro/opengl/redbook/redbook-E.pdf

and
http://www.lp23.com/files/tutorial_03.pdf

(I found them both at google)

Mikael

[This message has been edited by mikael_aronsson (edited 08-05-2003).]

chuks
08-06-2003, 05:56 AM
Hi,
Thanks a lot.