Package net.dermetfan.gdx.physics.box2d
Class PositionController
java.lang.Object
net.dermetfan.gdx.physics.box2d.PositionController
- Direct Known Subclasses:
PositionController.D,PositionController.P,PositionController.PD
public abstract class PositionController
extends java.lang.Object
moves a body to a position using forces
- Since:
- 0.11.1
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPositionController.Dthe derivative control loop componentstatic classPositionController.Pthe proportional control loop componentstatic classPositionController.PDa proportional-derivative controller -
Field Summary
Fields Modifier and Type Field Description static net.dermetfan.utils.Function<java.lang.Object,PositionController>defaultUserDataAccessorreturns the argument if it is a PositionControllerprotected static com.badlogic.gdx.math.Vector2vec2shared instance for internal use -
Constructor Summary
Constructors Constructor Description PositionController() -
Method Summary
Modifier and Type Method Description com.badlogic.gdx.math.Vector2applyForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point, boolean wake)applies the necessary force at the given pointcom.badlogic.gdx.math.Vector2applyForceToCenter(com.badlogic.gdx.physics.box2d.Body body, boolean wake)applies the necessary force at the center of mass of the Bodystatic voidapplyForceToCenter(com.badlogic.gdx.physics.box2d.World world, boolean wake)CallsapplyForceToCenterfor every Body with a PositionController in its user data.abstract com.badlogic.gdx.math.Vector2calculateForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point)abstract com.badlogic.gdx.math.Vector2calculateForceToCenter(com.badlogic.gdx.physics.box2d.Body body)static net.dermetfan.utils.Function<java.lang.Object,PositionController>getUserDataAccessor()static voidsetUserDataAccessor(net.dermetfan.utils.Function<java.lang.Object,PositionController> userDataAccessor)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
vec2
protected static final com.badlogic.gdx.math.Vector2 vec2shared instance for internal use -
defaultUserDataAccessor
public static final net.dermetfan.utils.Function<java.lang.Object,PositionController> defaultUserDataAccessorreturns the argument if it is a PositionController
-
-
Constructor Details
-
PositionController
public PositionController()
-
-
Method Details
-
applyForceToCenter
public static void applyForceToCenter(com.badlogic.gdx.physics.box2d.World world, boolean wake)CallsapplyForceToCenterfor every Body with a PositionController in its user data. The PositionController is accessed using theuserDataAccessor.- Parameters:
world- the world which Bodies to iterate over
-
calculateForce
public abstract com.badlogic.gdx.math.Vector2 calculateForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point)- Parameters:
point- the world point at which the force should be applied- Returns:
- the force to apply at the given point
-
calculateForceToCenter
public abstract com.badlogic.gdx.math.Vector2 calculateForceToCenter(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the force to apply at the center of mass of the Body
-
applyForce
public com.badlogic.gdx.math.Vector2 applyForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point, boolean wake)applies the necessary force at the given point- Parameters:
point- the world point at which to apply the force- Returns:
- the force applied, calculated by
calculateForce(Body, Vector2)
-
applyForceToCenter
public com.badlogic.gdx.math.Vector2 applyForceToCenter(com.badlogic.gdx.physics.box2d.Body body, boolean wake)applies the necessary force at the center of mass of the Body- Returns:
- the force applied, calculated by
calculateForceToCenter(Body)
-
getUserDataAccessor
public static net.dermetfan.utils.Function<java.lang.Object,PositionController> getUserDataAccessor()- Returns:
- the
userDataAccessor
-
setUserDataAccessor
public static void setUserDataAccessor(net.dermetfan.utils.Function<java.lang.Object,PositionController> userDataAccessor)- Parameters:
userDataAccessor- TheuserDataAccessorto set. If null,defaultUserDataAccessoris set.
-