Class: RotarySpringConstraint
physics/constraints/rotarySpring.RotarySpringConstraint
Represents a damped rotary spring joint between two CollisionObjects or a CollisionObject and itself.
This joint will aim to maintain the provided angle between the 2 bodies.
When the joint only consists of one body it will aim to keep that bodies rotation at the specified angle.
Setting anchor points for this constraint will have no affect.
Hierarchy
โณ
RotarySpringConstraint
Constructors
constructor
โข new RotarySpringConstraint(a, b, angle, stiffness, damping?)
Creates a new RotarySpringConstraint between two bodies.
Parameters
| Name | Type | Description |
|---|---|---|
a | CollisionObject | The first body |
b | CollisionObject | The second body |
angle | number | The resting angle of the spring |
stiffness | number | The stiffness of the spring |
damping? | number | The damping of the spring |
Overrides
Defined in
src/physics/constraints/rotarySpring.ts:40
โข new RotarySpringConstraint(opts)
Creates a new SpringConstraint with the given options.
Parameters
| Name | Type | Description |
|---|---|---|
opts | RotarySpringConstraintOptions | The constraint options |
Overrides
Defined in
src/physics/constraints/rotarySpring.ts:47
โข new RotarySpringConstraint(a, angle, stiffness, damping?)
Creates a new RotarySpringConstraint between a body and a point.
Parameters
| Name | Type | Description |
|---|---|---|
a | CollisionObject | The body to constrain |
angle | number | The resting angle of the spring. |
stiffness | number | The stiffness of the spring |
damping? | number | The damping of the spring |
Overrides
Defined in
src/physics/constraints/rotarySpring.ts:57
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
angle
โข angle: number
Defined in
src/physics/constraints/rotarySpring.ts:22
b
โข b: CollisionObject
Inherited from
Defined in
src/physics/constraints/constraint.ts:26
damping
โข damping: number
Defined in
src/physics/constraints/rotarySpring.ts:24
errorBias
โข errorBias: number
Inherited from
Defined in
src/physics/constraints/constraint.ts:32
inertiaSum
โข inertiaSum: number
Defined in
src/physics/constraints/rotarySpring.ts:26
jAcc
โข jAcc: number
Defined in
src/physics/constraints/rotarySpring.ts:29
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
stiffness
โข stiffness: number
Defined in
src/physics/constraints/rotarySpring.ts:23
targetWrn
โข targetWrn: number
Defined in
src/physics/constraints/rotarySpring.ts:27
wCoef
โข wCoef: number
Defined in
src/physics/constraints/rotarySpring.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
calcTorque
โธ Private calcTorque(): number
Calculates the torque required to correct the spring.
Returns
number
The torque required to correct the spring
Defined in
src/physics/constraints/rotarySpring.ts:140
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
Performs post solve operations.
Returns
void
Overrides
Defined in
src/physics/constraints/rotarySpring.ts:133
preSolve
โธ preSolve(dt): void
Prepares the spring for solving.
Parameters
| Name | Type | Description |
|---|---|---|
dt | number | The time since the last update |
Returns
void
Overrides
Defined in
src/physics/constraints/rotarySpring.ts:95
solve
โธ solve(dt): void
Applies the spring forces to the attached bodies.
Parameters
| Name | Type | Description |
|---|---|---|
dt | number | The time since the last update |
Returns
void
Overrides
Defined in
src/physics/constraints/rotarySpring.ts:118
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