Class PositionController.P

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

public static class PositionController.P
extends PositionController
the proportional control loop component
Since:
0.11.1
  • Nested Class Summary

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

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

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

    defaultUserDataAccessor, vec2
  • Constructor Summary

    Constructors
    Constructor Description
    P​(float gain, com.badlogic.gdx.math.Vector2 destination)  
    P​(com.badlogic.gdx.math.Vector2 gain, com.badlogic.gdx.math.Vector2 destination)  
  • Method Summary

    Modifier and Type Method Description
    static float calculateForce​(float gain, float pos, float dest)  
    static com.badlogic.gdx.math.Vector2 calculateForce​(float gainX, float gainY, float x, float y, float destX, float destY)  
    static com.badlogic.gdx.math.Vector2 calculateForce​(com.badlogic.gdx.math.Vector2 gain, com.badlogic.gdx.math.Vector2 pos, com.badlogic.gdx.math.Vector2 dest)  
    com.badlogic.gdx.math.Vector2 calculateForce​(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point)  
    com.badlogic.gdx.math.Vector2 calculateForceToCenter​(com.badlogic.gdx.physics.box2d.Body body)  
    com.badlogic.gdx.math.Vector2 getDestination()  
    com.badlogic.gdx.math.Vector2 getGain()  
    void setDestination​(com.badlogic.gdx.math.Vector2 destination)  
    void setGain​(com.badlogic.gdx.math.Vector2 gain)  

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

    applyForce, applyForceToCenter, applyForceToCenter, 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​(float gain, com.badlogic.gdx.math.Vector2 destination)
      Parameters:
      gain - the gain on both axes
      destination - the destination
    • P

      public P​(com.badlogic.gdx.math.Vector2 gain, com.badlogic.gdx.math.Vector2 destination)
      Parameters:
      gain - the gain
      destination - the destination
  • Method Details

    • calculateForce

      public static float calculateForce​(float gain, float pos, float dest)
      Parameters:
      gain - the gain
      pos - the current position
      dest - the setpoint
      Returns:
      gain * error
    • calculateForce

      public static com.badlogic.gdx.math.Vector2 calculateForce​(float gainX, float gainY, float x, float y, float destX, float destY)
      Returns:
      PositionController.vec2
      See Also:
      calculateForce(float, float, float)
    • calculateForce

      public static com.badlogic.gdx.math.Vector2 calculateForce​(com.badlogic.gdx.math.Vector2 gain, com.badlogic.gdx.math.Vector2 pos, com.badlogic.gdx.math.Vector2 dest)
      See Also:
      calculateForce(float, float, float, float, float, float)
    • calculateForce

      public com.badlogic.gdx.math.Vector2 calculateForce​(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point)
      Specified by:
      calculateForce in class PositionController
      point - the world point at which the force should be applied
      Returns:
      the force to apply at the given point
    • calculateForceToCenter

      public com.badlogic.gdx.math.Vector2 calculateForceToCenter​(com.badlogic.gdx.physics.box2d.Body body)
      Specified by:
      calculateForceToCenter in class PositionController
      Returns:
      the force to apply at the center of mass of the Body
    • getGain

      public com.badlogic.gdx.math.Vector2 getGain()
      Returns:
      the gain
    • setGain

      public void setGain​(com.badlogic.gdx.math.Vector2 gain)
      Parameters:
      gain - the gain to set
    • getDestination

      public com.badlogic.gdx.math.Vector2 getDestination()
      Returns:
      the destination
    • setDestination

      public void setDestination​(com.badlogic.gdx.math.Vector2 destination)
      Parameters:
      destination - the destination to set