API Docs for: 0.7.1
Show:

GearConstraint Class

Constrains the angle of two bodies to each other to be equal. If a gear ratio is not one, the angle of bodyA must be a multiple of the angle of bodyB.

Constructor

GearConstraint

(
  • bodyA
  • bodyB
  • [options]
)

Parameters:

  • bodyA Body
  • bodyB Body
  • [options] Object optional
    • [angle=0] Number optional

      Relative angle between the bodies. Will be set to the current angle between the bodies (the gear ratio is accounted for).

    • [ratio=1] Number optional

      Gear ratio.

    • [maxTorque] Number optional

      Maximum torque to apply.

Example:

var constraint = new GearConstraint(bodyA, bodyB);
        world.addConstraint(constraint);
        
var constraint = new GearConstraint(bodyA, bodyB, {
            ratio: 2,
            maxTorque: 1000
        });
        world.addConstraint(constraint);
        

Methods

getMaxTorque

() Number

Get the max torque for the constraint.

Returns:

Number:

setMaxTorque

(
  • torque
)

Set the max torque for the constraint.

Parameters:

  • torque Number

setRelaxation

(
  • relaxation
)

Set relaxation for this constraint.

Parameters:

  • relaxation Number

setStiffness

(
  • stiffness
)

Set stiffness for this constraint.

Parameters:

  • stiffness Number

update

()

Updates the internal constraint parameters before solve.

Properties

angle

Number

The relative angle

bodyA

Body

First body participating in the constraint.

bodyB

Body

Second body participating in the constraint.

collideConnected

Boolean

Set to true if you want the connected bodies to collide.

Default: true

equations

Array

Equations to be solved in this constraint

ratio

Number

The gear ratio.

type

Number

The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.