Package net.dermetfan.gdx.physics.box2d
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
-
Method Summary
Modifier and Type Method Description static floatcalculateTargetAngle(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 target)static floatcalculateTorque(float gain, float rotation, float target)floatcalculateTorque(com.badlogic.gdx.physics.box2d.Body body)java.lang.NumbergetAngle()java.lang.NumbergetGain()com.badlogic.gdx.math.Vector2getTarget()voidsetAngle(java.lang.Number angle)voidsetGain(java.lang.Number gain)voidsetTarget(com.badlogic.gdx.math.Vector2 target)Methods inherited from class net.dermetfan.gdx.physics.box2d.RotationController
applyTorque, applyTorque, getUserDataAccessor, setUserDataAccessorMethods 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- thegainangle- theangle
-
P
public P(java.lang.Number gain, com.badlogic.gdx.math.Vector2 target)- Parameters:
gain- thegaintarget- thetarget
-
P
public P(java.lang.Number gain, java.lang.Number angle, com.badlogic.gdx.math.Vector2 target)- Parameters:
gain- thegainangle- theangletarget- thetarget
-
-
Method Details
-
calculateTorque
public static float calculateTorque(float gain, float rotation, float target)- Parameters:
gain- the gainrotation- the current rotationtarget- 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 rotatetarget- 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:
calculateTorquein classRotationController- Returns:
- the torque to apply
-
getGain
public java.lang.Number getGain()- Returns:
- the
gain
-
setGain
public void setGain(java.lang.Number gain)- Parameters:
gain- thegainto set
-
getAngle
public java.lang.Number getAngle()- Returns:
- the
angle
-
setAngle
public void setAngle(java.lang.Number angle)- Parameters:
angle- theangleto set
-
getTarget
public com.badlogic.gdx.math.Vector2 getTarget()- Returns:
- the
target
-
setTarget
public void setTarget(com.badlogic.gdx.math.Vector2 target)- Parameters:
target- thetargetto set
-