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
โณ
PivotConstraintโณโณ
MouseConstraintโณโณ
TouchConstraint
Constructors
constructor
โข new PivotConstraint(a, b, point)
Creates a new PivotConstraint between two bodies.
Parameters
| Name | Type | Description |
|---|---|---|
a | CollisionObject | The first body |
b | CollisionObject | The second body |
point | vec2 | The point to join the bodies at in world space |
Overrides
Defined in
src/physics/constraints/pivot.ts:29
โข new PivotConstraint(opts)
Creates a new PivotConstraint with the given options.
Parameters
| Name | Type | Description |
|---|---|---|
opts | PivotConstraintOptions | The constraint options |
Overrides
Defined in
src/physics/constraints/pivot.ts:36
โข new PivotConstraint(a, point)
Creates a new PivotConstraint between a body and a point.
Parameters
| Name | Type | Description |
|---|---|---|
a | CollisionObject | The body to constrain |
point | vec2 | A point in world space |
Overrides
Defined in
src/physics/constraints/pivot.ts:44
Properties
a
โข a: CollisionObject
Inherited from
Defined in
src/physics/constraints/constraint.ts:22
anchorA
โข anchorA: vec2
Inherited from
Defined in
src/physics/constraints/constraint.ts:23
anchorB
โข anchorB: vec2
Inherited from
Defined in
src/physics/constraints/constraint.ts:27
b
โข b: CollisionObject
Inherited from
Defined in
src/physics/constraints/constraint.ts:26
bias
โข bias: vec2
Defined in
src/physics/constraints/pivot.ts:18
errorBias
โข errorBias: number
Inherited from
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
Defined in
src/physics/constraints/constraint.ts:33
maxForce
โข maxForce: number = Infinity
Inherited from
Defined in
src/physics/constraints/constraint.ts:35
point
โข point: vec2
Inherited from
Defined in
src/physics/constraints/constraint.ts:30
rotA
โข rotA: number = 0
Inherited from
Defined in
src/physics/constraints/constraint.ts:24
rotB
โข rotB: number = 0
Inherited from
Defined in
src/physics/constraints/constraint.ts:28
Methods
applyImpulses
โธ Protected applyImpulses(impulse, direction): void
Parameters
| Name | Type |
|---|---|
impulse | number |
direction | vec2 |
Returns
void
Inherited from
Defined in
src/physics/constraints/constraint.ts:111
โธ Protected applyImpulses(impulse): void
Parameters
| Name | Type |
|---|---|
impulse | vec2 |
Returns
void
Inherited from
Defined in
src/physics/constraints/constraint.ts:113
biasCoef
โธ Protected biasCoef(dt): number
Calculates the velocity bias coefficient.
Parameters
| Name | Type | Description |
|---|---|---|
dt | number | The time since the last update |
Returns
number
Inherited from
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
| Name | Type | Description |
|---|---|---|
pointA | vec2 | The anchor point on body a |
pointB | vec2 | The 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
Defined in
src/physics/constraints/constraint.ts:107
kScalar
โธ Protected kScalar(n): number
Computes the k scalar value for the constraint.
Parameters
| Name | Type | Description |
|---|---|---|
n | vec2 | The constraint's delta normal |
Returns
number
The k scalar value for the constraint
Inherited from
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
| Name | Type | Description |
|---|---|---|
body | CollisionObject | The body to calculate for |
r | vec2 | The anchor point on the body |
n | vec2 | The constraint's delta normal |
Returns
number
The k scalar value for the given body
Inherited from
Defined in
src/physics/constraints/constraint.ts:194
kTensor
โธ Protected kTensor(): mat2
Computes the k tensor matrix for the constraint.
Returns
mat2
k tensor matrix
Inherited from
Defined in
src/physics/constraints/constraint.ts:220
postSolve
โธ postSolve(): void
Applies the cached impulse.
Returns
void
Overrides
Defined in
src/physics/constraints/pivot.ts:119
preSolve
โธ preSolve(dt): void
Prepares for constraint solving.
Parameters
| Name | Type |
|---|---|
dt | number |
Returns
void
Overrides
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.
Parameters
| Name | Type | Description |
|---|---|---|
dt | number | The time since the last update |
Returns
void
Overrides
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
Defined in
src/physics/constraints/constraint.ts:141