Matter.Collision
The Matter.Collision
module contains methods for detecting collisions between a given pair of bodies.
For efficient detection between a list of bodies, see Matter.Detector
and Matter.Query
.
See Matter.Engine
for collision events.
Methods
Matter.Collision._findSupports
Finds supporting vertices given two bodies along a given direction using hill-climbing.
Returns
[vector]
Matter.Collision._overlapAxes
Find the overlap between two sets of vertices.
Matter.Collision.collides
Detect collision between two bodies.
Parameters
Returns
A collision record if detected, otherwise null
Properties / Options
The following properties if specified below are for objects created by Matter.Collision.create
and may be passed to it as options
.
The first body part represented by the collision (see also collision.parentA
).
The second body part represented by the collision (see also collision.parentB
).
A flag that indicates if the bodies were colliding when the collision was last updated.
Default: false
A Number
that represents the minimum separating distance between the bodies along the collision normal.
Default: 0
A normalised Vector
that represents the direction between the bodies that provides the minimum separating distance.
Default: { x: 0, y: 0 }
A reference to the pair using this collision record, if there is one.
Default: null
The first body represented by the collision (i.e. collision.bodyA.parent
).
The second body represented by the collision (i.e. collision.bodyB.parent
).
Collision.penetration
Vector
A Vector
that represents the direction and depth of the collision.
Default: { x: 0, y: 0 }
Collision.supportCount
Number
The number of active supports for this collision found in collision.supports
.
Note: Only the first collision.supportCount
items of collision.supports
are active.
Therefore use collision.supportCount
instead of collision.supports.length
when iterating the active supports.
Default: 0
An array of body vertices that represent the support points in the collision.
Note: Only the first collision.supportCount
items of collision.supports
are active.
Therefore use collision.supportCount
instead of collision.supports.length
when iterating the active supports.
These are the deepest vertices (along the collision normal) of each body that are contained by the other body's vertices.
Default: []
A normalised Vector
that is the tangent direction to the collision normal.
Default: { x: 0, y: 0 }