Package jsim.forces
Class GravityForce
java.lang.Object
jsim.forces.GravityForce
- All Implemented Interfaces:
ForceGenerator
Applies gravitational acceleration to all dynamic, non-static bodies.
Gravity is uniform (not per-body — attach a custom ForceGenerator for buoyancy
or other per-body gravity modifications).
-
Constructor Summary
ConstructorsConstructorDescriptionGravityForce(List<RigidBody> bodies) Default gravity pointing in −Z (WPILib field convention).GravityForce(List<RigidBody> bodies, double gx, double gy, double gz) Gravity with a custom acceleration vector. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(double dt) Apply forces/torques to whichever bodies this generator influences.
-
Constructor Details
-
GravityForce
Default gravity pointing in −Z (WPILib field convention).- Parameters:
bodies- all bodies to apply gravity to
-
GravityForce
Gravity with a custom acceleration vector.- Parameters:
bodies- all bodies to apply gravity togx- gravitational acceleration X component (m/s²)gy- gravitational acceleration Y component (m/s²)gz- gravitational acceleration Z component (m/s²)
-
-
Method Details
-
apply
public void apply(double dt) Description copied from interface:ForceGeneratorApply forces/torques to whichever bodies this generator influences.- Specified by:
applyin interfaceForceGenerator- Parameters:
dt- the fixed simulation timestep in seconds
-