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
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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) getAngle()getGain()com.badlogic.gdx.math.Vector2voidvoidvoidsetTarget(com.badlogic.gdx.math.Vector2 target) Methods inherited from class net.dermetfan.gdx.physics.box2d.RotationController
applyTorque, applyTorque, getUserDataAccessor, setUserDataAccessor
-
Constructor Details
-
P
- Parameters:
gain- thegainangle- theangle
-
P
- Parameters:
gain- thegaintarget- thetarget
-
P
- 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
- Returns:
- the
gain
-
setGain
- Parameters:
gain- thegainto set
-
getAngle
- Returns:
- the
angle
-
setAngle
- 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
-