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
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.dermetfan.gdx.physics.box2d.RotationController

    RotationController.D, RotationController.P, RotationController.PD
  • Field Summary

    Fields inherited from class net.dermetfan.gdx.physics.box2d.RotationController

    defaultUserDataAccessor
  • Constructor Summary

    Constructors
    Constructor Description
    P​(java.lang.Number gain, com.badlogic.gdx.math.Vector2 target)  
    P​(java.lang.Number gain, java.lang.Number angle)  
    P​(java.lang.Number gain, java.lang.Number angle, com.badlogic.gdx.math.Vector2 target)  
  • Method Summary

    Modifier and Type Method Description
    static float calculateTargetAngle​(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 target)  
    static float calculateTorque​(float gain, float rotation, float target)  
    float calculateTorque​(com.badlogic.gdx.physics.box2d.Body body)  
    java.lang.Number getAngle()  
    java.lang.Number getGain()  
    com.badlogic.gdx.math.Vector2 getTarget()  
    void setAngle​(java.lang.Number angle)  
    void setGain​(java.lang.Number gain)  
    void setTarget​(com.badlogic.gdx.math.Vector2 target)  

    Methods inherited from class net.dermetfan.gdx.physics.box2d.RotationController

    applyTorque, applyTorque, getUserDataAccessor, setUserDataAccessor

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • P

      public P​(java.lang.Number gain, java.lang.Number angle)
      Parameters:
      gain - the gain
      angle - the angle
    • P

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

      public P​(java.lang.Number gain, java.lang.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 java.lang.Number getGain()
      Returns:
      the gain
    • setGain

      public void setGain​(java.lang.Number gain)
      Parameters:
      gain - the gain to set
    • getAngle

      public java.lang.Number getAngle()
      Returns:
      the angle
    • setAngle

      public void setAngle​(java.lang.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