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 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
- thegain
angle
- theangle
-
P
public P(java.lang.Number gain, com.badlogic.gdx.math.Vector2 target)- Parameters:
gain
- thegain
target
- thetarget
-
P
public P(java.lang.Number gain, java.lang.Number angle, com.badlogic.gdx.math.Vector2 target)- Parameters:
gain
- thegain
angle
- theangle
target
- 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:
calculateTorque
in 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
- thegain
to set
-
getAngle
public java.lang.Number getAngle()- Returns:
- the
angle
-
setAngle
public void setAngle(java.lang.Number angle)- Parameters:
angle
- theangle
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
- thetarget
to set
-