Skip to main content

Class: PivotConstraint

physics/constraints/pivot.PivotConstraint

Represents a pivot joint between two CollisionObjects or a CollisionObject and a point.

This constraint will keep the object's joined together by their anchor points at the given point.

Hierarchy

Constructors

constructor

โ€ข new PivotConstraint(a, b, point)

Creates a new PivotConstraint between two bodies.

Parameters

NameTypeDescription
aCollisionObjectThe first body
bCollisionObjectThe second body
pointvec2The point to join the bodies at in world space

Overrides

Constraint.constructor

Defined in

src/physics/constraints/pivot.ts:29

โ€ข new PivotConstraint(opts)

Creates a new PivotConstraint with the given options.

Parameters

NameTypeDescription
optsPivotConstraintOptionsThe constraint options

Overrides

Constraint.constructor

Defined in

src/physics/constraints/pivot.ts:36

โ€ข new PivotConstraint(a, point)

Creates a new PivotConstraint between a body and a point.

Parameters

NameTypeDescription
aCollisionObjectThe body to constrain
pointvec2A point in world space

Overrides

Constraint.constructor

Defined in

src/physics/constraints/pivot.ts:44

Properties

a

โ€ข a: CollisionObject

Inherited from

Constraint.a

Defined in

src/physics/constraints/constraint.ts:22


anchorA

โ€ข anchorA: vec2

Inherited from

Constraint.anchorA

Defined in

src/physics/constraints/constraint.ts:23


anchorB

โ€ข anchorB: vec2

Inherited from

Constraint.anchorB

Defined in

src/physics/constraints/constraint.ts:27


b

โ€ข b: CollisionObject

Inherited from

Constraint.b

Defined in

src/physics/constraints/constraint.ts:26


bias

โ€ข bias: vec2

Defined in

src/physics/constraints/pivot.ts:18


errorBias

โ€ข errorBias: number

Inherited from

Constraint.errorBias

Defined in

src/physics/constraints/constraint.ts:32


jAcc

โ€ข jAcc: vec2

Defined in

src/physics/constraints/pivot.ts:19


k

โ€ข k: mat2

Defined in

src/physics/constraints/pivot.ts:20


maxBias

โ€ข maxBias: number = Infinity

Inherited from

Constraint.maxBias

Defined in

src/physics/constraints/constraint.ts:33


maxForce

โ€ข maxForce: number = Infinity

Inherited from

Constraint.maxForce

Defined in

src/physics/constraints/constraint.ts:35


point

โ€ข point: vec2

Inherited from

Constraint.point

Defined in

src/physics/constraints/constraint.ts:30


rotA

โ€ข rotA: number = 0

Inherited from

Constraint.rotA

Defined in

src/physics/constraints/constraint.ts:24


rotB

โ€ข rotB: number = 0

Inherited from

Constraint.rotB

Defined in

src/physics/constraints/constraint.ts:28

Methods

applyImpulses

โ–ธ Protected applyImpulses(impulse, direction): void

Parameters

NameType
impulsenumber
directionvec2

Returns

void

Inherited from

Constraint.applyImpulses

Defined in

src/physics/constraints/constraint.ts:111

โ–ธ Protected applyImpulses(impulse): void

Parameters

NameType
impulsevec2

Returns

void

Inherited from

Constraint.applyImpulses

Defined in

src/physics/constraints/constraint.ts:113


biasCoef

โ–ธ Protected biasCoef(dt): number

Calculates the velocity bias coefficient.

Parameters

NameTypeDescription
dtnumberThe time since the last update

Returns

number

Inherited from

Constraint.biasCoef

Defined in

src/physics/constraints/constraint.ts:182


calculateRelativeVelocity

โ–ธ Protected calculateRelativeVelocity(pointA, pointB): vec2

Calculate the relative velocity of the bodies in the constraint.

Parameters

NameTypeDescription
pointAvec2The anchor point on body a
pointBvec2The anchor point on body b

Returns

vec2

The relative velocity between body a and b or body a and the anchor point

Inherited from

Constraint.calculateRelativeVelocity

Defined in

src/physics/constraints/constraint.ts:164


isBodyToPoint

โ–ธ isBodyToPoint(): boolean

Determines wether or not the constraint is between a body and a point.

Returns

boolean

Wether or not the constraint is between a body and a point.

Inherited from

Constraint.isBodyToPoint

Defined in

src/physics/constraints/constraint.ts:107


kScalar

โ–ธ Protected kScalar(n): number

Computes the k scalar value for the constraint.

Parameters

NameTypeDescription
nvec2The constraint's delta normal

Returns

number

The k scalar value for the constraint

Inherited from

Constraint.kScalar

Defined in

src/physics/constraints/constraint.ts:205


kScalarBody

โ–ธ Protected kScalarBody(body, r, n): number

Computes the k scalar value for the given body.

Parameters

NameTypeDescription
bodyCollisionObjectThe body to calculate for
rvec2The anchor point on the body
nvec2The constraint's delta normal

Returns

number

The k scalar value for the given body

Inherited from

Constraint.kScalarBody

Defined in

src/physics/constraints/constraint.ts:194


kTensor

โ–ธ Protected kTensor(): mat2

Computes the k tensor matrix for the constraint.

see Chipmunk2D kTensor

Returns

mat2

k tensor matrix

Inherited from

Constraint.kTensor

Defined in

src/physics/constraints/constraint.ts:220


postSolve

โ–ธ postSolve(): void

Applies the cached impulse.

Returns

void

Overrides

Constraint.postSolve

Defined in

src/physics/constraints/pivot.ts:119


preSolve

โ–ธ preSolve(dt): void

Prepares for constraint solving.

Parameters

NameType
dtnumber

Returns

void

Overrides

Constraint.preSolve

Defined in

src/physics/constraints/pivot.ts:65


solve

โ–ธ solve(dt): void

Computes and applies the impulse to keep the bodies at the joint's length.

see Chipmunk2D Pin Joint

see MatterJS Constraint

see Dyn4j Distance Constraint

see Constraints and Solvers

Parameters

NameTypeDescription
dtnumberThe time since the last update

Returns

void

Overrides

Constraint.solve

Defined in

src/physics/constraints/pivot.ts:95


updateAnchors

โ–ธ Protected updateAnchors(): void

Updates the constraint's anchor points to match the rotations of their bodies.

Returns

void

Inherited from

Constraint.updateAnchors

Defined in

src/physics/constraints/constraint.ts:141