Packageorg.generalrelativity.foam.dynamics.collision.fine.sat
Classpublic class PolygonPolygonDetector
ImplementsIFineCollisionDetector



Public Properties
 PropertyDefined by
  body1 : IBody
first body in detection
PolygonPolygonDetector
  body2 : IBody
second body in detection
PolygonPolygonDetector
  minDistance : Number
minimum distance along the pentration axis required to resolve penetration
PolygonPolygonDetector
  penetrationAxis : Vector
most direct vector out of penetration
PolygonPolygonDetector
Public Methods
 MethodDefined by
  
Creates a new PolygonPolygonDetector
PolygonPolygonDetector
  
getContacts():Array
Generates contacts based on found collision.
PolygonPolygonDetector
  
hasCollision():Boolean
Determines whether the 2 bodies are intersecting.
PolygonPolygonDetector
Public Constants
 ConstantDefined by
  EPSILON : Number = 0.1
[static] margin for parallel determination in multi-point contact
PolygonPolygonDetector
Property detail
body1property
public var body1:IBody

first body in detection

body2property 
public var body2:IBody

second body in detection

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
PolygonPolygonDetector()constructor
public function PolygonPolygonDetector(body1:IBody, body2:IBody)

Creates a new PolygonPolygonDetector

Parameters
body1:IBody — first body in detection
 
body2:IBody — second body in detection
Method detail
getContacts()method
public function getContacts():Array

Generates contacts based on found collision.

Given 2 convex polygons there are 3 different contact scenarios:

   1. Vertex - Edge
   2. Edge - Edge
   3. Vertex - Vertex
   
The third (vertex-vertex) is so unlikely that we can disregard it all together. Edge - edge is reduced from what can be seen as an infinite number of contact points (line on line), to 2 (innermost vertices). Vertex - edge works as is.

First step in defining the contact point in world coordinates is resolving any penetration. Once resolved, the bodies' shared point(s) is the contact point(s). Each found point is built into a Contact instance and returned in an Array.

In determining contact points, we once again consider the 3 scenarios above. Remembering that we're ignoring vertex - vertex, we're left needing a means to determine whether we're dealing with vertex - edge or edge - edge. What we do is iterate over each vertex, finding the point furthest along the penetrationAxis. In the more likely case of vertex - edge, we'll find 1 vertex on 1 body and 2 on the other. The 2 constitute the body's edge involved in contact- This means we can take the single point on the other body as our point of contact. If, however, we find 2 points as the extreme on each body, we're dealing with edge - edge. In this scenario we use the middle 2 vertices involved as the 2 points of contact.

Returns
Array — Array of contacts

See also

Contact
PhysicsEngine
hasCollision()method 
public function hasCollision():Boolean

Determines whether the 2 bodies 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.

Returns
Boolean — true given penetration, false otherwise

See also

Constant detail
EPSILONconstant
public static const EPSILON:Number = 0.1

margin for parallel determination in multi-point contact