Class GearJoint

All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class GearJoint extends Constraint
A joint that couples the angular velocities of two bodies, based on Bullet's btGearConstraint.

From the Bullet manual:

The btGearConstraint will couple the angular velocity for two bodies around given local axis and ratio.

  • Field Details

    • logger2

      public static final Logger logger2
      message logger for this class
  • Constructor Details

    • GearJoint

      public GearJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f axisInA, Vector3f axisInB)
      Instantiate a double-ended GearJoint with a 1:1 ratio.

      To be effective, the joint must be added to the PhysicsSpace of both bodies. Also, the bodies must be distinct and at least one of them must be dynamic.

      Parameters:
      rigidBodyA - the body for the A end (not null, alias created)
      rigidBodyB - the body for the B end (not null, alias created)
      axisInA - the A body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
      axisInB - the B body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
    • GearJoint

      public GearJoint(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f axisInA, Vector3f axisInB, float ratio)
      Instantiate a double-ended GearJoint with the specified gear ratio.

      To be effective, the joint must be added to the PhysicsSpace of both bodies. Also, the bodies must be distinct and at least one of them must be dynamic.

      Parameters:
      rigidBodyA - the body for the A end (not null, alias created)
      rigidBodyB - the body for the B end (not null, alias created)
      axisInA - the A body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
      axisInB - the B body's axis of rotation in its local coordinates (unit vector, not null, unaffected)
      ratio - the number of revolutions the A body should make for each revolution of the B body
  • Method Details

    • getAxisA

      public Vector3f getAxisA(Vector3f storeResult)
      Copy A body's axis of rotation.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the A body's axis of rotation in its local coordinates (either storeResult or new vector)
    • getAxisB

      public Vector3f getAxisB(Vector3f storeResult)
      Copy the B body's axis of rotation.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the B body's axis of rotation in its local coordinates (either storeResult or new vector)
    • getRatio

      public float getRatio()
      Get the gear ratio.
      Returns:
      the number of revolutions the A body makes for each revolution of the B body
    • setAxisA

      public void setAxisA(Vector3f axisInA)
      Alter the A body's axis of rotation.
      Parameters:
      axisInA - the desired axis in local coordinates (unit vector, not null, unaffected)
    • setAxisB

      public void setAxisB(Vector3f axisInB)
      Alter the B body's axis of rotation.
      Parameters:
      axisInB - the axisInB axis in local coordinates (unit vector, not null, unaffected)
    • setRatio

      public void setRatio(float ratio)
      Alter the joint's gear ratio.
      Parameters:
      ratio - the number of revolutions the A body should make for each revolution of the B body (default=1)