PlayN Game Library Tutorial #5 – Box2D Revolute Joints

The revolute joint in Box2d is a type of axle or a hinge which allows a body to rotate around a set point. The point of rotation is defined on each body that is connected to the revolute joint. It can be used to simulate wheels, cogs, rotors, chains, ropes or pendulums. It can also be used to simulate marionette type joints, rotating poles among other things. The revolute joint has the following properties:

  1. localAnchorA and localAnchorB indicates the point of rotation on each body (A and B)
  2. enableMotor enables the motor on the joint
  3. motorSpeed the speed of the motor
  4. maxMotorTorque the torque or power supplied by the motor, if the weight is too large the motor might not be able to move it
  5. enableLimit indicates if the joint is limited to specific angles , the default is unlimited - i.e. full rotation is allowed
  6. lowerAngle the smallest limit angle
  7. upperAngle the largest limit angle
  8. referenceAngle the angle which is considered 0 for this joint, the default is 0. This can be used to make thinking about related joint angles easier

In this example we have recreated a double pendulum, also called a chaotic pendulum. The reason it is called chaotic is because the path of the pendulum is highly dependent on the initial conditions of the system. In the example, after the pendulum is created it is given a small push to start moving, the resulting trajectory is very erratic.





Leave a Reply

Your email address will not be published. Required fields are marked *