| Package | org.generalrelativity.foam.dynamics.collision.fine.sat |
| Class | public class PolygonPolygonDetector |
| Implements | IFineCollisionDetector |
| Property | Defined 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 | ||
| Method | Defined 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 | ||
| Constant | Defined by | ||
|---|---|---|---|
| EPSILON : Number = 0.1 [static] margin for parallel determination in multi-point contact
| PolygonPolygonDetector | ||
| body1 | property |
public var body1:IBodyfirst body in detection
| body2 | property |
public var body2:IBodysecond body in detection
| minDistance | property |
public var minDistance:Numberminimum distance along the pentration axis required to resolve penetration
| penetrationAxis | property |
public var penetrationAxis:Vectormost direct vector out of penetration
| PolygonPolygonDetector | () | constructor |
public function PolygonPolygonDetector(body1:IBody, body2:IBody)Creates a new PolygonPolygonDetector
Parametersbody1:IBody — first body in detection
|
|
body2:IBody — second body in detection
|
| getContacts | () | method |
public function getContacts():ArrayGenerates contacts based on found collision.
Given 2 convex polygons there are 3 different contact scenarios:
1. Vertex - Edge 2. Edge - Edge 3. Vertex - VertexThe 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.
Array — Array of contacts
|
See also
| hasCollision | () | method |
public function hasCollision():BooleanDetermines 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.
ReturnsBoolean — true given penetration, false otherwise
|
See also
| EPSILON | constant |
public static const EPSILON:Number = 0.1margin for parallel determination in multi-point contact