10 KiB
Planck.js API Doc › Globals › GearJoint
Class: GearJoint
A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant
The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length. Warning: You have to manually destroy the gear joint if joint1 or joint2 is destroyed.
This definition requires two existing revolute or prismatic joints (any combination will work).
Hierarchy
-
↳ GearJoint
Index
Constructors
Properties
Methods
- getAnchorA
- getAnchorB
- getBodyA
- getBodyB
- getCollideConnected
- getJoint1
- getJoint2
- getNext
- getRatio
- getReactionForce
- getReactionTorque
- getType
- getUserData
- initVelocityConstraints
- isActive
- setRatio
- setUserData
- shiftOrigin
- solvePositionConstraints
- solveVelocityConstraints
Constructors
constructor
+ new GearJoint(def: GearJointDef): GearJoint
Overrides Joint.constructor
Defined in src/dynamics/joint/GearJoint.ts:122
Parameters:
| Name | Type |
|---|---|
def |
GearJointDef |
Returns: GearJoint
+ new GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint
Overrides Joint.constructor
Defined in src/dynamics/joint/GearJoint.ts:124
Parameters:
| Name | Type |
|---|---|
def |
GearJointOpt |
bodyA |
Body |
bodyB |
Body |
joint1 |
RevoluteJoint | PrismaticJoint |
joint2 |
RevoluteJoint | PrismaticJoint |
ratio? |
number |
Returns: GearJoint
Properties
Static TYPE
▪ TYPE: "gear-joint" = 'gear-joint' as 'gear-joint'
Defined in src/dynamics/joint/GearJoint.ts:82
Methods
getAnchorA
▸ getAnchorA(): Vec2
Overrides Joint.getAnchorA
Defined in src/dynamics/joint/GearJoint.ts:302
Get the anchor point on bodyA in world coordinates.
Returns: Vec2
getAnchorB
▸ getAnchorB(): Vec2
Overrides Joint.getAnchorB
Defined in src/dynamics/joint/GearJoint.ts:309
Get the anchor point on bodyB in world coordinates.
Returns: Vec2
getBodyA
▸ getBodyA(): Body
Defined in src/dynamics/Joint.ts:159
Get the first body attached to this joint.
Returns: Body
getBodyB
▸ getBodyB(): Body
Defined in src/dynamics/Joint.ts:166
Get the second body attached to this joint.
Returns: Body
getCollideConnected
▸ getCollideConnected(): boolean
Inherited from Joint.getCollideConnected
Defined in src/dynamics/Joint.ts:190
Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.
Returns: boolean
getJoint1
▸ getJoint1(): Joint
Defined in src/dynamics/joint/GearJoint.ts:273
Get the first joint.
Returns: Joint
getJoint2
▸ getJoint2(): Joint
Defined in src/dynamics/joint/GearJoint.ts:280
Get the second joint.
Returns: Joint
getNext
▸ getNext(): Joint
Defined in src/dynamics/Joint.ts:173
Get the next joint the world joint list.
Returns: Joint
getRatio
▸ getRatio(): number
Defined in src/dynamics/joint/GearJoint.ts:295
Get the gear ratio.
Returns: number
getReactionForce
▸ getReactionForce(inv_dt: number): Vec2
Overrides Joint.getReactionForce
Defined in src/dynamics/joint/GearJoint.ts:316
Get the reaction force on bodyB at the joint anchor in Newtons.
Parameters:
| Name | Type |
|---|---|
inv_dt |
number |
Returns: Vec2
getReactionTorque
▸ getReactionTorque(inv_dt: number): number
Overrides Joint.getReactionTorque
Defined in src/dynamics/joint/GearJoint.ts:323
Get the reaction torque on bodyB in N*m.
Parameters:
| Name | Type |
|---|---|
inv_dt |
number |
Returns: number
getType
▸ getType(): string
Defined in src/dynamics/Joint.ts:152
Get the type of the concrete joint.
Returns: string
getUserData
▸ getUserData(): unknown
Inherited from Joint.getUserData
Defined in src/dynamics/Joint.ts:177
Returns: unknown
initVelocityConstraints
▸ initVelocityConstraints(step: TimeStep): void
Overrides Joint.initVelocityConstraints
Defined in src/dynamics/joint/GearJoint.ts:328
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void
isActive
▸ isActive(): boolean
Defined in src/dynamics/Joint.ts:145
Short-cut function to determine if either body is inactive.
Returns: boolean
setRatio
▸ setRatio(ratio: number): void
Defined in src/dynamics/joint/GearJoint.ts:287
Set the gear ratio.
Parameters:
| Name | Type |
|---|---|
ratio |
number |
Returns: void
setUserData
▸ setUserData(data: unknown): void
Inherited from Joint.setUserData
Defined in src/dynamics/Joint.ts:181
Parameters:
| Name | Type |
|---|---|
data |
unknown |
Returns: void
shiftOrigin
▸ shiftOrigin(newOrigin: Vec2): void
Inherited from Joint.shiftOrigin
Defined in src/dynamics/Joint.ts:217
Shift the origin for any points stored in world coordinates.
Parameters:
| Name | Type |
|---|---|
newOrigin |
Vec2 |
Returns: void
solvePositionConstraints
▸ solvePositionConstraints(step: TimeStep): boolean
Overrides Joint.solvePositionConstraints
Defined in src/dynamics/joint/GearJoint.ts:465
This returns true if the position errors are within tolerance.
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: boolean
solveVelocityConstraints
▸ solveVelocityConstraints(step: TimeStep): void
Overrides Joint.solveVelocityConstraints
Defined in src/dynamics/joint/GearJoint.ts:425
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void