Packageorg.MARS.dynamics.collision.fine.sat
Classpublic class CirclePolygonDetector
ImplementsIFineCollisionDetector

Detects a collision between a circle and a convex polygon. Convexity is assumed.

This detection scheme is based on the Separating Axis Theorem (SAT). The idea is that given 2 convex objects (two-dimensionally in this case), if an axis can be found that does not intersect either, they are not touching. This makes intuitive sense because convex objects can't "wrap around" each other. Also, the geometries that make this assumption hold, offer the axes we need to check. Specifically, we test along the axis given by each polygonal edge normal.

Aside from its generality, what makes SAT so robust is that it offers an "easy out." As soon as one separating axis is found, no further consideration is necessary- the objects do not intersect.

See also

AxisProjection
CircleAxisProjection
IFineCollisionDetector
Contact
PhysicsEngine


Public Properties
 PropertyDefined by
  body : Polygon
IBody to detect
CirclePolygonDetector
  circle : Circle
Circle to detect
CirclePolygonDetector
  minDistance : Number
minimum distance along the pentration axis required to resolve penetration
CirclePolygonDetector
  penetrationAxis : Vector
most direct vector out of penetration
CirclePolygonDetector
Public Methods
 MethodDefined by
  
Creates a new CirclePolygonDetector
CirclePolygonDetector
  
getContacts():Array
Gets point of contact in world-coordinates

In the case of Circle vs.

CirclePolygonDetector
  
hasCollision():Boolean
Determines whether the #circle and #body are intersecting.
CirclePolygonDetector
Property detail
bodyproperty
public var body:Polygon

IBody to detect

circleproperty 
public var circle:Circle

Circle to detect

minDistanceproperty 
public var minDistance:Number

minimum distance along the pentration axis required to resolve penetration

penetrationAxisproperty 
public var penetrationAxis:Vector

most direct vector out of penetration

Constructor detail
CirclePolygonDetector()constructor
public function CirclePolygonDetector(circle:Circle, body:Polygon)

Creates a new CirclePolygonDetector

Parameters
circle:Circle — Circle to check for collision
 
body:Polygon — body to check for collision against
Method detail
getContacts()method
public function getContacts():Array

Gets point of contact in world-coordinates

In the case of Circle vs. anything, there will be at most 1 point of contact. That point of contact will always be on the circle's edge and can be found by moving out from the circle's position in the direction of the penetration axis by the length of the radius.

Returns
Array — Array with single Contact

See also

PolygonPolygonDetector.getContacts
hasCollision()method 
public function hasCollision():Boolean

Determines whether the #circle and #body are intersecting.

We check each axis as a contender for separation between the bodies. It's usually quite more likely in an application that objects AREN'T intersecting. For that reason, this algorithm is constructed such that it terminates as soon as possible given non-intersection. It's good to think of collision as absolute worst case scenario- its detection and resolution are the most processor intensive aspects of FOAM.

With the case of a circle, we check each of the polygon's offered axes and then the axis that's created between the closest vertex on the polygon and the Circle.

Returns
Boolean — true given penetration, false otherwise

See also