- RigidBodyCollision
- CornerEdgeCollision

bilateral
checkConsistent
closeEnough
contact
distanceToHalfGap
getAcceleration
getClassName
getConnector
getDetectedTime
getDistance
getElasticity
getEstimatedTime
getImpact1
getImpact2
getImpulse
getLateralVelocity
getNormalBody
getNormalVelocity
getPerpNormal
getPrimaryBody
getR1
getR2
getRelativeVelocity
getU1
getU2
getVelocity
hasBody
hasEdge
hasVertex
illegalState
isColliding
isTouching
needsHandling
setDetectedTime
setNeedsHandling
similarTo
toString
updateCollision

- new
Corner (vertex, normalEdge): CornerEdgeCollisionEdge Collision #### Parameters

#### Returns CornerEdgeCollision

ballNormal : boolean = false

true if the normal object's edge is curved

ballObject : boolean = false

true if the 'primary' object's edge is curved

creator: string = ''

for debugging, unique code tells where this was generated

distance: number = NaN

distance between objects; negative = penetration

`Protected`

distancedistanceTol_ : number

distance tolerance is used to decide when bodies are touching.

force: number = NaN

amount of force applied at a contact point

point of impact, in global coords

second impact point needed for Rope because the impact points are far apart. OPTIONAL point of impact on normalBody, in global coords

impulse: number = NaN

amount of impulse applied during collision

joint: boolean

whether this is a bilateral constraint which can both push and pull

normal pointing outward from normalObj, in world coords

object corresponding to the normal (its edge defines the normal vector)

`Private`

normaledge of normal body

normalFixed : boolean

true = normal is constant

derivative of normal vector with respect to time

'primary' object whose corner or edge is colliding

`Private`

primaryedge next to vertex

`Private`

primaryother edge next to vertex; null for decorated vertex

radius1: number = NaN

radius of curvature at impact1, for primary body; negative means concave

radius2: number = NaN

radius of curvature at impact1, for normal body; negative means concave

`Private`

u2_vector from normal body CM to normal edge's circle center, in world coords. Cached value to speed up performance.

`Protected`

velocityvelocityTol_ : number

velocity tolerance used to determine if an object is in contact with another object. See ImpulseSim.getVelocityTol.

`Private`

vertexvertex of primary body, between primaryEdge and primaryEdge2

- bilateral(): boolean
Returns true if this represents a bilateral constraint which can both push and pull; for example a Joint between two objects.

#### Returns boolean

true if this is a bilateral constraint

- close
Enough (allowTiny): boolean Whether close enough to the point when this Collision can be handled. The

`allowTiny`

parameter exists because of cases where a small distance collision cannot be backed-up in time to get near to the preferred target 'half gap' distance.#### Parameters

##### allowTiny: boolean

regard as 'close enough' Collisions that have smaller distance than distance accuracy would normally allow

#### Returns boolean

true if close enough to the point when this Collision can be handled.

- get
Elasticity (): number Returns the elasticity used when calculating collisions; a value of 1.0 means perfect elasticity where the kinetic energy after collision is the same as before (extremely bouncy), while a value of 0 means no elasticity (no bounce). A collision uses the lesser elasticity value of the two bodies involved.

#### Returns number

elasticity used when calculating collisions, a number from 0 to 1.

- get
Impact2 (): null | Vector Returns point of impact on normal body, in global coords. For example, this is needed for Rope because the impact points are far apart. Often null when only Vertex.isEndPoint is needed.

#### Returns null | Vector

point of impact on normal body, in global coords, or null

- get
Normal (): RigidBodyBody Returns the normal body involved in the collision, which defines the normal vector. The classic situation is that a vertex on the primary body is colliding into an edge on the normal body, but there are many variations on this.

#### Returns RigidBody

the normal body involved in the collision

- get
Normal (): numberVelocity Returns the relative normal velocity based on current velocity of the bodies. Negative velocity means the objects moving towards each other, positive velocity means they are moving apart.

#### Returns number

relative normal velocity between the two bodies at the point of contact.

- get
Primary (): RigidBodyBody Returns the primary body involved in the collision. The primary body does not define the normal. The classic situation is that a vertex on the primary body is colliding into an edge on the normal body, but there are many variations on this.

#### Returns RigidBody

the primary body involved in the collision

- get
Relative (): VectorVelocity Returns the difference in velocity of the two impact points of the collision based on current velocity of the bodies.

`let V = velocity of center of mass (CM); let R = distance vector CM to contact point let w = angular velocity w x R = (0, 0, w) x (Rx, Ry, 0) = (-w Ry, w Rx, 0) velocity of corner = V + w x R = (Vx - w Ry, Vy + w Rx, 0) relative velocity = Vab = Va + wa x Ra - Vb - wb x Rb`

For curved edge we use the

`U`

vector (from center of mass to edge's circle center) instead of`R`

vector (from center of mass to point of impact). Because what matters is not the motion of the individual point but instead the entire curved edge. Consider that for a ball with center of mass at center of the circle, rotation doesn't change the distance at all.#### Returns Vector

the velocity vector of this collision

- get
U2 (): Vector Returns vector from center of mass of normal body to either point of impact or to center of circular edge in world coords. Uses the second impact point if appropriate.

#### Returns Vector

vector from center of mass of normal body to either point of impact or to center of circular edge, in world coords

- has
Body (body): boolean Whether this collision involves the given RigidBody

#### Parameters

##### body: RigidBody

the RigidBody of interest

#### Returns boolean

whether collision involves the given RigidBody

- has
Edge (edge): boolean Whether this collision involves the given edge. If given edge is null, then always returns false.

#### Parameters

##### edge: null | Edge

the Edge of interest

#### Returns boolean

whether collision involves the given Edge

- has
Vertex (v): boolean Whether this collision involves the given vertex

#### Parameters

##### v: Vertex

the Vertex of interest

#### Returns boolean

whether collision involves the given Vertex

- is
Colliding (): boolean Returns true if this represents a collision state, generally when two objects are interpenetrating. The collision search mechanism implemented by AdvanceStrategy.advance operates to set the simulation at a time very close to but just before any Collision is happening, see getEstimatedTime.

#### Returns boolean

`true`

if this represents a collision state

- set
Detected (time): voidTime Stores the time when this collision was detected, stores the current distance and velocity as the detected distance and detected velocity, and estimates when the collision occurred.

#### Parameters

##### time: number

when this collision is detected

#### Returns void

#### Throws

if the detected time has been previously set

- set
Needs (needsHandling): voidHandling Mark this Collision as one that

*needs handling*because it is has caused the collision engine to backup in time in order to resolve this Collision. This is useful because after backing up in time, a Collision may no longer report itself as isColliding.#### Parameters

##### needsHandling: boolean

true if this Collision needs to be resolved

#### Returns void

- similar
To (c): boolean Returns whether this collision could be the same as another collision. Often there are several collisions found at a single location by the various collision detection mechanisms, and this is used when deciding which collision of those to keep.

#### Parameters

##### c: RigidBodyCollision

the other collision

#### Returns boolean

true if the two collisions are possibly the same collision

- update
Collision (time): void Updates the information in the collision to reflect current position and velocity of bodies. Changes the impact point to be the nearest point between the bodies (as long as this point is reasonably close to the original impact point). Then update the normal, R vectors, etc.

This is used when handling collisions because the collisions are found post-collision, but are handled pre-collision. Therefore, we need to update the information to correspond to the pre-collision arrangement of the bodies.

Doing this fixes inaccurate collisions; for example, a ball that hits a wall at an angle would wrongly acquire spin if the collision were not updated to the current pre-collision information.

Assumes that the bodies have been updated for their current location, by for example RigidBodySim.modifyObjects.

#### Parameters

##### time: number

the current simulation time

#### Returns void

Generated using TypeDoc

A RigidBodyCollision between a corner Vertex and an Edge.