Package net.dermetfan.gdx.physics.box2d
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
-
Method Summary
Modifier and Type Method Description static floatcalculateForce(float gain, float pos, float dest)static com.badlogic.gdx.math.Vector2calculateForce(float gainX, float gainY, float x, float y, float destX, float destY)static com.badlogic.gdx.math.Vector2calculateForce(com.badlogic.gdx.math.Vector2 gain, com.badlogic.gdx.math.Vector2 pos, com.badlogic.gdx.math.Vector2 dest)com.badlogic.gdx.math.Vector2calculateForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point)com.badlogic.gdx.math.Vector2calculateForceToCenter(com.badlogic.gdx.physics.box2d.Body body)com.badlogic.gdx.math.Vector2getDestination()com.badlogic.gdx.math.Vector2getGain()voidsetDestination(com.badlogic.gdx.math.Vector2 destination)voidsetGain(com.badlogic.gdx.math.Vector2 gain)Methods inherited from class net.dermetfan.gdx.physics.box2d.PositionController
applyForce, applyForceToCenter, applyForceToCenter, getUserDataAccessor, setUserDataAccessorMethods 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 axesdestination- thedestination
-
P
public P(com.badlogic.gdx.math.Vector2 gain, com.badlogic.gdx.math.Vector2 destination)- Parameters:
gain- thegaindestination- thedestination
-
-
Method Details
-
calculateForce
public static float calculateForce(float gain, float pos, float dest)- Parameters:
gain- the gainpos- the current positiondest- 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) -
calculateForce
public com.badlogic.gdx.math.Vector2 calculateForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point)- Specified by:
calculateForcein classPositionControllerpoint- 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:
calculateForceToCenterin classPositionController- 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- thegainto set
-
getDestination
public com.badlogic.gdx.math.Vector2 getDestination()- Returns:
- the
destination
-
setDestination
public void setDestination(com.badlogic.gdx.math.Vector2 destination)- Parameters:
destination- thedestinationto set
-