View Full Version : Calculation of normals
12-18-2000, 03:25 AM
How can I calculate normal to a polygon?
Assume that I have a polygon of vertices v1,v2,v3,v4.
Can you give me some info.
[This message has been edited by Ramesh (edited 12-18-2000).]
12-18-2000, 04:24 AM
For flat polygons you only need one normale because its everywhere the same.
Take 3 Points of you Surface, for example a,b,c and make two vectors:
/calculate the vector v1
/calculate the vector v2
/do the cross product with v1 and v2
n1x=(v1y*v2z - v1z*v2y);
n1y=(v1z*v2x - v1x*v2z);
n1z=(v1x*v2y - v1y*v2x);
/divide the normal through its length
/...and put the normal in the glNormal function
If the polygon isn't flat (with a minimum of 4 points) you need to calculate the normal of every edge with the vector before and after every vertex
[This message has been edited by Spaceman (edited 12-18-2000).]
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.