java.lang.Object
com.marginallyclever.ro3.node.Node
com.marginallyclever.ro3.node.nodes.HingeJoint

public class HingeJoint extends Node

a HingeJoint is a joint that can rotate around the local Z axis.

a HingeJoint should be attached to a child Pose referenced as the axle. In this way the axle's parent Pose can be thought of as the initial pose at zero degrees. This helps prevent drift over time.

This class provides several functionalities:

  • It can set and get the angle of rotation.
  • It can set and get the minimum and maximum angles of rotation.
  • It can set and get the velocity of rotation.
  • It can set and get the acceleration of rotation.
  • It can set and get the axle Pose.
  • It can update the axle's location in space based on the angle of rotation.
  • It can serialize and deserialize itself to and from JSON format.

This class also provides several properties:

  • angle: the angle of rotation in degrees.
  • minAngle: the minimum angle of rotation in degrees.
  • maxAngle: the maximum angle of rotation in degrees.
  • velocity: the velocity of rotation in degrees per second.
  • acceleration: the acceleration of rotation in degrees per second squared.
  • axle: the Pose that the HingeJoint is attached to.
  • Constructor Details

    • HingeJoint

      public HingeJoint()
    • HingeJoint

      public HingeJoint(String name)
  • Method Details

    • getComponents

      public void getComponents(List<JPanel> list)
      Description copied from class: Node
      Build a Swing Component that represents this Node.
      Overrides:
      getComponents in class Node
      Parameters:
      list - the list to add components to.
    • update

      public void update(double dt)
      Description copied from class: Node
      Called every frame.
      Overrides:
      update in class Node
      Parameters:
      dt - the time since the last frame.
    • toJSON

      public org.json.JSONObject toJSON()
      Description copied from class: Node
      Serialize this node and its children to a JSON object and its children. Classes that override this method should call super.toJSON() first, then add to the object returned.
      Overrides:
      toJSON in class Node
      Returns:
      the JSON object.
    • fromJSON

      public void fromJSON(org.json.JSONObject from)
      Description copied from class: Node
      Deserialize this node and its children from a JSON object and its children. Classes that override this method should call super.fromJSON(). When they do it will trigger the creation of child nodes. The child nodes will then call their own fromJSON() methods.
      Overrides:
      fromJSON in class Node
      Parameters:
      from - the JSON object to read from.
    • getAngle

      public double getAngle()
    • setAngle

      public void setAngle(double degrees)
    • getMinAngle

      public double getMinAngle()
    • setMinAngle

      public void setMinAngle(double v)
    • getMaxAngle

      public double getMaxAngle()
    • setMaxAngle

      public void setMaxAngle(double v)
    • getVelocity

      public double getVelocity()
    • setVelocity

      public void setVelocity(double velocity)
    • getAcceleration

      public double getAcceleration()
    • setAcceleration

      public void setAcceleration(double acceleration)
    • getAxle

      public Pose getAxle()
    • setAxle

      public void setAxle(Pose subject)