Class NewHinge

All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class NewHinge extends New6Dof
A 3 degree-of-freedom Constraint that mimics ODE's Hinge2 joint, such as might be used to model one of the front wheels on a motor vehicle.

Rotation is enabled only for the Z and X axes, with limits on Z-axis rotation. The X axis rotates freely. Translation is enabled only for the Z axis, with a suspension spring.

Inspired by Bullet's btHinge2Constraint.

  • Field Details

    • logger3

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

    • NewHinge

      public NewHinge(PhysicsRigidBody rigidBodyA, PhysicsRigidBody rigidBodyB, Vector3f anchor, Vector3f axis1, Vector3f axis2)
      Instantiate a double-ended constraint.

      To be effective, the constraint 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)
      anchor - initial anchor location for the constraint frame (in physics-space coordinates, not null, unaffected)
      axis1 - initial Z-axis direction for the constraint frame (in physics-space coordinates, not null, not zero, unaffected)
      axis2 - initial X-axis direction for the constraint frame (in physics-space coordinates, not null, not zero, unaffected)
  • Method Details

    • getAnchor

      public Vector3f getAnchor(Vector3f storeResult)
      Determine the anchor location for body A.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the location (either storeResult or a new vector, not null)
    • getAnchor2

      public Vector3f getAnchor2(Vector3f storeResult)
      Determine the anchor location for body B.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the location (either storeResult or a new vector, not null)
    • getAngle1

      public float getAngle1()
      Determine the rotation angle for axis1.
      Returns:
      the rotation angle (in radians)
    • getAngle2

      public float getAngle2()
      Determine the rotation angle for axis2.
      Returns:
      the rotation angle (in radians)
    • getAxis1

      public Vector3f getAxis1(Vector3f storeResult)
      Determine the direction of axis1.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a direction vector (either storeResult or a new vector, not null)
    • getAxis2

      public Vector3f getAxis2(Vector3f storeResult)
      Determine the direction of axis2.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a direction vector (either storeResult or a new vector, not null)
    • setLowerLimit

      public final void setLowerLimit(float angle1Min)
      Alter the lower limit for axis1 rotation.
      Parameters:
      angle1Min - the desired angle (in radians)
    • setUpperLimit

      public final void setUpperLimit(float angle1Max)
      Alter the upper limit for axis1 rotation.
      Parameters:
      angle1Max - the desired angle (in radians)