Class GearJoint

java.lang.Object
com.codename1.gaming.physics.box2d.dynamics.joints.Joint
com.codename1.gaming.physics.box2d.dynamics.joints.GearJoint

public class GearJoint extends Joint
A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length.
Warning:
The revolute and prismatic joints must be attached to fixed bodies (which must be body1 on those joints)., You have to manually destroy the gear joint if joint1 or joint2 is destroyed.
  • Constructor Details

  • Method Details

    • getAnchorA

      public void getAnchorA(Vec2 argOut)
      Description copied from class: Joint
      get the anchor point on bodyA in world coordinates.
      Specified by:
      getAnchorA in class Joint
      Parameters:
      argOut - receives the anchor point
    • getAnchorB

      public void getAnchorB(Vec2 argOut)
      Description copied from class: Joint
      get the anchor point on bodyB in world coordinates.
      Specified by:
      getAnchorB in class Joint
      Parameters:
      argOut - receives the anchor point
    • getReactionForce

      public void getReactionForce(float inv_dt, Vec2 argOut)
      Description copied from class: Joint
      get the reaction force on body2 at the joint anchor in Newtons.
      Specified by:
      getReactionForce in class Joint
      Parameters:
      inv_dt - the inverse of the time step
      argOut - receives the reaction force
    • getReactionTorque

      public float getReactionTorque(float inv_dt)
      Description copied from class: Joint
      get the reaction torque on body2 in N*m.
      Specified by:
      getReactionTorque in class Joint
      Parameters:
      inv_dt -
      Returns:
    • setRatio

      public void setRatio(float argRatio)
    • getRatio

      public float getRatio()
    • initVelocityConstraints

      public void initVelocityConstraints(SolverData data)
      Specified by:
      initVelocityConstraints in class Joint
    • solveVelocityConstraints

      public void solveVelocityConstraints(SolverData data)
      Specified by:
      solveVelocityConstraints in class Joint
    • getJoint1

      public Joint getJoint1()
    • getJoint2

      public Joint getJoint2()
    • solvePositionConstraints

      public boolean solvePositionConstraints(SolverData data)
      Description copied from class: Joint
      This returns true if the position errors are within tolerance.
      Specified by:
      solvePositionConstraints in class Joint
      Parameters:
      data - the solver state for this step
      Returns:
      true if the position errors are within tolerance