🔒 Locked
Normals
Advertisement
Original Post
The order you supply the source vectors to the cross product you use to create your normal determine which way the normal points.
A search for "The right hand rule" should get you some diagrams to illustrate, such as: http://mathworld.wolfram.com/Right-HandRule.html
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
A search for "The right hand rule" should get you some diagrams to illustrate, such as: http://mathworld.wolfram.com/Right-HandRule.html
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
It works in 2D as well, however you have to use a slighly different process. Let''s say you have your points in clockwise order:
What you first do is create a vector normal to your polygon. Since you''re working in 2D, you don''t even need any math. This vector can be (0,0,1). Now, if you go around and create vectors with your points, (v2 - v1), (v3 - v2), (v4 - v3), and (v1 - v4), you can take the crossproduct between the normal vector you created, and each of the side vectors, and your result will be a vector within the 2D plane perpendicular to the side, exactly what you''re looking for. All you have to do is normalized it. So, for an N-sided polygon, you have your normal vector (0,0,1), and your side vectors (v2 - v1), (v3 - v2), (v4 - v3), ... (vN - vN-1), (v1 - vN). Take the crossproduct between (0,0,1) and each of these vectors, and normalize.
v1 v2
.................
. .
. .
. .
. .
. .
. .
. .
.................
v4 v3
What you first do is create a vector normal to your polygon. Since you''re working in 2D, you don''t even need any math. This vector can be (0,0,1). Now, if you go around and create vectors with your points, (v2 - v1), (v3 - v2), (v4 - v3), and (v1 - v4), you can take the crossproduct between the normal vector you created, and each of the side vectors, and your result will be a vector within the 2D plane perpendicular to the side, exactly what you''re looking for. All you have to do is normalized it. So, for an N-sided polygon, you have your normal vector (0,0,1), and your side vectors (v2 - v1), (v3 - v2), (v4 - v3), ... (vN - vN-1), (v1 - vN). Take the crossproduct between (0,0,1) and each of these vectors, and normalize.
I remember trying a similar thing at one time. From what i can recall, i just peformed a point test to see if the normal was pointing inwards. Or just enforce clockwise winding then your normals will always point outwards when using the cross-product
quote:
Original post by MattS423
Thats great, zipster, but is it pointing away from the polygonal region, like in my diagram?
Yes. However it depends on two things, a) the winding of your points, and b) which order you do the crossproduct in. If your points are in clockwise order, and you do the crossproduct between the artificial normal and the side vector (in that order), then the normal will point outwards. If your points are counter-clockwise, then you need to switch the order of the crossproduct, so that it's the side and then the artificial normal.
[edited by - Zipster on May 22, 2003 12:35:35 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement