| Package | org.MARS.dynamics.collision.fine.sat |
| Class | public class CircleCircleDetector |
| Implements | IFineCollisionDetector |
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
| Property | Defined by | ||
|---|---|---|---|
| circle1 : Circle
circle 1 to check for collision
| CircleCircleDetector | ||
| circle2 : Circle
circle 2 to check for collision
| CircleCircleDetector | ||
| dist : Number distance between circles
| CircleCircleDetector | ||
| Method | Defined by | ||
|---|---|---|---|
|
Creates a new CircleCircleDetector
| CircleCircleDetector | ||
|
getContacts():Array
| CircleCircleDetector | ||
|
hasCollision():Boolean
Determines whether 2 circles are overlapping
This method simply decides whether the circles are closer than the sum of their radii. | CircleCircleDetector | ||
| circle1 | property |
public var circle1:Circlecircle 1 to check for collision
| circle2 | property |
public var circle2:Circlecircle 2 to check for collision
| dist | property |
public var dist:Numberdistance between circles
| CircleCircleDetector | () | constructor |
public function CircleCircleDetector(circle1:Circle, circle2:Circle)Creates a new CircleCircleDetector
Parameterscircle1:Circle — circle 1 to check for collisions
|
|
circle2:Circle — circle 2 to check for collisions
|
| getContacts | () | method |
public function getContacts():Array
Returns
Array |
| hasCollision | () | method |
public function hasCollision():BooleanDetermines whether 2 circles are overlapping
This method simply decides whether the circles are closer than the sum of their radii. It does so using the square of the distance to avoid an expensive square root call given the quite likely scenario that the circle's do not collide.
ReturnsBoolean — true if they intersect, false otherwise
|