Skip to main content

Class: Manifold

physics/manifold.Manifold

Information about a collision which has occured between two objects.

Constructors

constructor

โ€ข new Manifold(a, b, collision, gravity, delta)

Creates a Manifold describing a collision between a and b in detail.

Parameters

NameTypeDescription
aCollisionObjectFirst collision object
bCollisionObjectSecond collision object
collisionCollisionResultCollisionResult from collision test
gravityvec2The collision world's gravity vector
deltanumberThe time since the last update

Defined in

src/physics/manifold.ts:103

Properties

a

โ€ข a: CollisionObject

An object in the collision.

Defined in

src/physics/manifold.ts:40


b

โ€ข b: CollisionObject

Another object in the collision.

Defined in

src/physics/manifold.ts:45


contactPoints

โ€ข contactPoints: ContactPoint[]

The contact points of the collision.

Defined in

src/physics/manifold.ts:80


depth

โ€ข depth: number

The penetration depth of the collision.

Defined in

src/physics/manifold.ts:50


df

โ€ข df: number

dynamic friction scalar.

Defined in

src/physics/manifold.ts:75


edges

โ€ข edges: Edge[] = []

store used edges [inc, ref]

Defined in

src/physics/manifold.ts:85


epsilon

โ€ข epsilon: number

Minimum restitution between a and b.

Defined in

src/physics/manifold.ts:65


isDead

โ€ข isDead: boolean = false

Defined in

src/physics/manifold.ts:92


normal

โ€ข normal: vec2

The collision normal, should always point from a to b.

Defined in

src/physics/manifold.ts:55


penetration

โ€ข penetration: vec2

The penetration vector, this is the collision normal scaled by the penetration depth.

Defined in

src/physics/manifold.ts:60


positionImpulse

โ€ข positionImpulse: Object

Type declaration

NameType
avec2
bvec2

Defined in

src/physics/manifold.ts:87


sf

โ€ข sf: number

static friction scalar.

Defined in

src/physics/manifold.ts:70

Methods

bestEdge

โ–ธ Private bestEdge(obj, direction): Edge

Finds the best edge of a CollisionObject in a given direction.

The best edge is defined as the edge most perpendicular to the given direction.

Parameters

NameTypeDescription
objCollisionObjectThe collision object to calculate the edge for
directionvec2The direction in which to calculate the edge

Returns

Edge

The best edge of obj for the direction given

Defined in

src/physics/manifold.ts:461


calculateContactPoints

โ–ธ Private calculateContactPoints(): ContactPoint[]

Calculates the contact points of the collision.

see Dyn4j Contact Points

Returns

ContactPoint[]

The points of contact for the collision

Defined in

src/physics/manifold.ts:362


clipPoints

โ–ธ Private clipPoints(p0, p1, direction, o): ContactPoint[]

Clips the edge points (p0, p1) if they are past o along the direction.

Parameters

NameTypeDescription
p0ContactPointThe first point to clip
p1ContactPointThe second point to clip
directionvec2The direction to clip in
onumberThe vector to clip past

Returns

ContactPoint[]

Defined in

src/physics/manifold.ts:499


compareContacts

โ–ธ Private compareContacts(c1, c2): boolean

Compares two contact points using a distance heuristic to determine wether they should be considered the same contact.

Parameters

NameTypeDescription
c1ContactPointA contact point
c2ContactPointA contact point

Returns

boolean

If the 2 contact points match

Defined in

src/physics/manifold.ts:227


kill

โ–ธ kill(): void

Marks the manifold as dead and decrements the objects involved's totalContacts counts.

Returns

void

Defined in

src/physics/manifold.ts:236


mergeManifold

โ–ธ Private mergeManifold(m, contacts): void

Merge this manifold with the given manifold and contact points.

Parameters

NameTypeDescription
mManifoldThe manifold to merge with
contactsContactPoint[]The manifold's new contact points

Returns

void

Defined in

src/physics/manifold.ts:205


preStepImpulse

โ–ธ preStepImpulse(delta): void

Precompute some additional information about the contact points for impulse resolution.

Calculates and applies accumulative impulse.

Parameters

NameTypeDescription
deltanumberThe time since the last udpate

Returns

void

Defined in

src/physics/manifold.ts:296


solvePositionImpulse

โ–ธ solvePositionImpulse(delta): void

Calculates the position impulse for objects a and b in the manifold.

see MatterJS Position Solving

Parameters

NameTypeDescription
deltanumberThe time since the last update

Returns

void

Defined in

src/physics/manifold.ts:251


translateEdge

โ–ธ Private translateEdge(edge, v): void

Translates the provided edge by the given vector.

Parameters

NameTypeDescription
edgeEdgeThe edge to translate
vvec2The vector to translate by

Returns

void

Defined in

src/physics/manifold.ts:550


translateIncEdge

โ–ธ translateIncEdge(v): void

Translates the manifold's incident edge by the given vector.

Parameters

NameTypeDescription
vvec2The vector to translate by

Returns

void

Defined in

src/physics/manifold.ts:540


update

โ–ธ update(m): void

Parameters

NameType
mManifold

Returns

void

Defined in

src/physics/manifold.ts:158