# Polygon outward facing normals

This topic is 1215 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys,

A general question about building polygons in 2D.

Given a set of vertices which compose a polygon we know that the lines between the vertices can have two facing normals.

Algorithmically, for a random polygon, how does one ensure that all normals are facing outwards, that is, away from the center of mass (given a point mass system).

Thanks,

Mike

##### Share on other sites
By enforcing a particular winding order. For example, if you decide to define all polygons in clockwise order (when facing) them the normal of each segment is the left hand perpendicular (y, -x).

Otherwise not sure there is a well defined answer but I could be wrong. I may also mean -y, x above, need a bit of paper to be sure :)

##### Share on other sites

Thanks for the help guys, that makes sense.

I need to ask you a question Randy about your physics engine if you don't mind. I have been stuyding your tutorials for a couple of months now with Ian Millington's Game Physics Engine Develeopment.

You seperate your entities using what you call slop, however, Ian uses a more intuitive seperation along the normal in proportion to the inverse masses (which you also implement)

Thanks,

Mike

##### Share on other sites

That's probably a good post for another topic, but that's ok we can talk about it here. The slop is just a small factor to allow objects to penetrate each other ever so slightly. This helps a little bit to reduce jitter. If we try to drive separation to exactly 0 when we solve overlap overshoot is more likely to occur. It's like a small margin of error where we consider the separation "good enough" and don't try to resolve the overlap.

Ian Millington is most surely doing something nearly identical, but perhaps presented in a different manner. He also continues to try to create what he calls "resting contacts". In my opinion these are just hacky work arounds to help the naive impulse solvers in Impulse Engine and Millington's Cyclone Engine with jitter.

I should note that while Millington's and my Impulse Engine are good places for a first draft of a physics engine, if you'd like to continue studying more professional technique's Erin Catto's public resources are industry standard. Just a note!

Hope that helps!

Edited by Randy Gaul

• 23
• 10
• 19
• 15
• 14