iDevGames Forums
Getting the Normal for a polygon. - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Getting the Normal for a polygon. (/thread-1511.html)



Getting the Normal for a polygon. - Jaden - Apr 2, 2009 09:16 PM

A quick question, how can I get the normal for a polygon if all I have is the (x,y,z) for the 4 corners of said polygon? Any links that would explain the math behind this would also be appreciative.

Thanks!


Getting the Normal for a polygon. - IBethune - Apr 3, 2009 12:46 AM

First, you need to think about whether the 4-points of the polygon are coplanar (i.e. they lie in the same plane). If not, you can't define a single face normal for the polygon since it's not flat.

In general, 3 points in space can be used to define a plane, so pick three points on your plane (three of the vertices, call them A,B,C). Construct vectors AB and AC (any combinations will do). Take the vector cross product of AB & AC and you will get a vector that is normal (perpendicular) to the plane. Depending on your needs you may wish to normalise the vector by scaling it by 1/normal_length so it has unit magnitude.

Cheers

- Iain


Getting the Normal for a polygon. - Jaden - Apr 3, 2009 01:30 PM

Ah! That was just enough information to get it working! Thanks a ton.


Getting the Normal for a polygon. - Nosredna - May 1, 2009 01:47 PM

It's not a polygon if the points aren't coplanar.