Class RotationController.P

java.lang.Object
net.dermetfan.gdx.physics.box2d.RotationController
net.dermetfan.gdx.physics.box2d.RotationController.P
Enclosing class:
RotationController

public static class RotationController.P extends RotationController
the proportional control loop component
Since:
0.11.1
  • Constructor Details

    • P

      public P(Number gain, Number angle)
      Parameters:
      gain - the gain
      angle - the angle
    • P

      public P(Number gain, com.badlogic.gdx.math.Vector2 target)
      Parameters:
      gain - the gain
      target - the target
    • P

      public P(Number gain, Number angle, com.badlogic.gdx.math.Vector2 target)
      Parameters:
      gain - the gain
      angle - the angle
      target - the target
  • Method Details

    • calculateTorque

      public static float calculateTorque(float gain, float rotation, float target)
      Parameters:
      gain - the gain
      rotation - the current rotation
      target - the setpoint
      Returns:
      gain * error normalized between -pi and pi
    • calculateTargetAngle

      public static float calculateTargetAngle(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 target)
      Parameters:
      body - the Body to rotate
      target - The point to rotate towards. May be null in which case zero is returned.
      Returns:
      the angle to rotate towards
    • calculateTorque

      public float calculateTorque(com.badlogic.gdx.physics.box2d.Body body)
      Specified by:
      calculateTorque in class RotationController
      Returns:
      the torque to apply
    • getGain

      public Number getGain()
      Returns:
      the gain
    • setGain

      public void setGain(Number gain)
      Parameters:
      gain - the gain to set
    • getAngle

      public Number getAngle()
      Returns:
      the angle
    • setAngle

      public void setAngle(Number angle)
      Parameters:
      angle - the angle to set
    • getTarget

      public com.badlogic.gdx.math.Vector2 getTarget()
      Returns:
      the target
    • setTarget

      public void setTarget(com.badlogic.gdx.math.Vector2 target)
      Parameters:
      target - the target to set