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
  • 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

      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

      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
      Parameters:
      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