# Polygon outward facing normals

## 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

A little more explanation I posted a couple days ago here: http://gamedev.stackexchange.com/a/92092/30974

##### 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)

What are the advantages/disadvantages of seperatiing Millington's way vs your slop?

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

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ### Forum Statistics

• Total Topics
628282
• Total Posts
2981811

• 9
• 10
• 11
• 17
• 15