2021-05-11 18:30:36 -07:00

15 KiB
Raw Permalink Blame History

Planck.js API Doc › Globals › RevoluteJoint

Class: RevoluteJoint

A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated.

Hierarchy

  • Joint

    ↳ RevoluteJoint

Index

Constructors

Properties

Methods

Constructors

constructor

+ new RevoluteJoint(def: RevoluteJointDef): RevoluteJoint

Overrides Joint.constructor

Defined in src/dynamics/joint/RevoluteJoint.ts:156

Parameters:

Name Type
def RevoluteJointDef

Returns: RevoluteJoint

+ new RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2): RevoluteJoint

Overrides Joint.constructor

Defined in src/dynamics/joint/RevoluteJoint.ts:158

Parameters:

Name Type
def RevoluteJointOpt
bodyA Body
bodyB Body
anchor Vec2

Returns: RevoluteJoint

Properties

Static TYPE

▪ TYPE: "revolute-joint" = 'revolute-joint' as 'revolute-joint'

Defined in src/dynamics/joint/RevoluteJoint.ts:131

Methods

enableLimit

▸ enableLimit(flag: boolean): void

Defined in src/dynamics/joint/RevoluteJoint.ts:368

Enable/disable the joint limit.

Parameters:

Name Type
flag boolean

Returns: void


enableMotor

▸ enableMotor(flag: boolean): void

Defined in src/dynamics/joint/RevoluteJoint.ts:316

Enable/disable the joint motor.

Parameters:

Name Type
flag boolean

Returns: void


getAnchorA

▸ getAnchorA(): Vec2

Overrides Joint.getAnchorA

Defined in src/dynamics/joint/RevoluteJoint.ts:409

Get the anchor point on bodyA in world coordinates.

Returns: Vec2


getAnchorB

▸ getAnchorB(): Vec2

Overrides Joint.getAnchorB

Defined in src/dynamics/joint/RevoluteJoint.ts:416

Get the anchor point on bodyB in world coordinates.

Returns: Vec2


getBodyA

▸ getBodyA(): Body

Inherited from Joint.getBodyA

Defined in src/dynamics/Joint.ts:159

Get the first body attached to this joint.

Returns: Body


getBodyB

▸ getBodyB(): Body

Inherited from Joint.getBodyB

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


getJointAngle

▸ getJointAngle(): number

Defined in src/dynamics/joint/RevoluteJoint.ts:291

Get the current joint angle in radians.

Returns: number


getJointSpeed

▸ getJointSpeed(): number

Defined in src/dynamics/joint/RevoluteJoint.ts:300

Get the current joint angle speed in radians per second.

Returns: number


getLocalAnchorA

▸ getLocalAnchorA(): Vec2

Defined in src/dynamics/joint/RevoluteJoint.ts:270

The local anchor point relative to bodyA's origin.

Returns: Vec2


getLocalAnchorB

▸ getLocalAnchorB(): Vec2

Defined in src/dynamics/joint/RevoluteJoint.ts:277

The local anchor point relative to bodyB's origin.

Returns: Vec2


getLowerLimit

▸ getLowerLimit(): number

Defined in src/dynamics/joint/RevoluteJoint.ts:380

Get the lower joint limit in radians.

Returns: number


getMaxMotorTorque

▸ getMaxMotorTorque(): number

Defined in src/dynamics/joint/RevoluteJoint.ts:354

Returns: number


getMotorSpeed

▸ getMotorSpeed(): number

Defined in src/dynamics/joint/RevoluteJoint.ts:341

Get the motor speed in radians per second.

Returns: number


getMotorTorque

▸ getMotorTorque(inv_dt: number): number

Defined in src/dynamics/joint/RevoluteJoint.ts:325

Get the current motor torque given the inverse time step. Unit is N*m.

Parameters:

Name Type
inv_dt number

Returns: number


getNext

▸ getNext(): Joint

Inherited from Joint.getNext

Defined in src/dynamics/Joint.ts:173

Get the next joint the world joint list.

Returns: Joint


getReactionForce

▸ getReactionForce(inv_dt: number): Vec2

Overrides Joint.getReactionForce

Defined in src/dynamics/joint/RevoluteJoint.ts:423

Get the reaction force given the inverse time step. Unit is N.

Parameters:

Name Type
inv_dt number

Returns: Vec2


getReactionTorque

▸ getReactionTorque(inv_dt: number): number

Overrides Joint.getReactionTorque

Defined in src/dynamics/joint/RevoluteJoint.ts:431

Get the reaction torque due to the joint limit given the inverse time step. Unit is N*m.

Parameters:

Name Type
inv_dt number

Returns: number


getReferenceAngle

▸ getReferenceAngle(): number

Defined in src/dynamics/joint/RevoluteJoint.ts:284

Get the reference angle.

Returns: number


getType

▸ getType(): string

Inherited from Joint.getType

Defined in src/dynamics/Joint.ts:152

Get the type of the concrete joint.

Returns: string


getUpperLimit

▸ getUpperLimit(): number

Defined in src/dynamics/joint/RevoluteJoint.ts:387

Get the upper joint limit in radians.

Returns: number


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/RevoluteJoint.ts:435

Parameters:

Name Type
step TimeStep

Returns: void


isActive

▸ isActive(): boolean

Inherited from Joint.isActive

Defined in src/dynamics/Joint.ts:145

Short-cut function to determine if either body is inactive.

Returns: boolean


isLimitEnabled

▸ isLimitEnabled(): boolean

Defined in src/dynamics/joint/RevoluteJoint.ts:361

Is the joint limit enabled?

Returns: boolean


isMotorEnabled

▸ isMotorEnabled(): boolean

Defined in src/dynamics/joint/RevoluteJoint.ts:309

Is the joint motor enabled?

Returns: boolean


setLimits

▸ setLimits(lower: number, upper: number): void

Defined in src/dynamics/joint/RevoluteJoint.ts:394

Set the joint limits in radians.

Parameters:

Name Type
lower number
upper number

Returns: void


setMaxMotorTorque

▸ setMaxMotorTorque(torque: number): void

Defined in src/dynamics/joint/RevoluteJoint.ts:348

Set the maximum motor torque, usually in N-m.

Parameters:

Name Type
torque number

Returns: void


setMotorSpeed

▸ setMotorSpeed(speed: number): void

Defined in src/dynamics/joint/RevoluteJoint.ts:332

Set the motor speed in radians per second.

Parameters:

Name Type
speed 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/RevoluteJoint.ts:657

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/RevoluteJoint.ts:546

Parameters:

Name Type
step TimeStep

Returns: void