- java.lang.Object
-
- org.arakhne.afc.math.physics.PhysicsUtil
-
public final class PhysicsUtil extends Object
Some physic utility functions.Definitions:
- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:49
- Author:
- Christophe BOHRHAUER
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathphysics
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static double
acceleration(double previousSpeed, double currentSpeed, double dt)
Replies the new acceleration according to a previous velocity and a current velocity, and given time.static PhysicsEngine
getPhysicsEngine()
Replies the current physics engine.static double
motionNewtonEuler1Law(double speed, double dt)
Compute and replies a motion according to Newton-Euler-1 equations for motion.static double
motionNewtonEuler1Law1D(double velocity, double minSpeed, double maxSpeed, double dt)
Compute and replies a motion according to Newton-Euler-1 equations for motion.static void
motionNewtonEuler1Law1D5(Vector1D<?,?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector1D<?,?,?> result)
Compute and replies a motion according to Newton-Euler-1 equations for motion.static void
motionNewtonEuler1Law1D5(Vector2D<?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector2D<?,?> result)
Deprecated, for removal: This API element is subject to removal in a future version.static void
motionNewtonEuler1Law2D(Vector2D<?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector2D<?,?> result)
Compute and replies a motion according to Newton-Euler-1 equations for motion.static void
motionNewtonEuler1Law2D5(Vector3D<?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector3D<?,?> result)
Compute and replies a motion according to Newton-Euler-1 equations for motion.static void
motionNewtonEuler1Law3D(Vector3D<?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector3D<?,?> result)
Compute and replies a motion according to Newton-Euler-1 equations for motion.static double
motionNewtonLaw(double speed, double acceleration, double dt)
Compute and replies a motion according to high school physics Newton's equations for motion.static double
motionNewtonLaw1D(double velocity, double minSpeed, double maxSpeed, double acceleration, double minAcceleration, double maxAcceleration, double dt)
Compute and replies a motion according to high school physics Newton's equations for motion.static void
motionNewtonLaw1D5(Vector1D<?,?,?> velocity, double minSpeed, double maxSpeed, Vector1D<?,?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector1D<?,?,?> result)
Compute and replies a motion according to high school physics Newton's equations for motion.static void
motionNewtonLaw1D5(Vector2D<?,?> velocity, double minSpeed, double maxSpeed, Vector2D<?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector2D<?,?> result)
Deprecated, for removal: This API element is subject to removal in a future version.static void
motionNewtonLaw2D(Vector2D<?,?> velocity, double minSpeed, double maxSpeed, Vector2D<?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector2D<?,?> result)
Compute and replies a motion according to high school physics Newton's equations for motion.static void
motionNewtonLaw2D5(Vector3D<?,?> velocity, double minSpeed, double maxSpeed, Vector3D<?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector3D<?,?> result)
Compute and replies a motion according to high school physics Newton's equations for motion.static void
motionNewtonLaw3D(Vector3D<?,?> velocity, double minSpeed, double maxSpeed, Vector3D<?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector3D<?,?> result)
Compute and replies a motion according to high school physics Newton's equations for motion.static PhysicsEngine
setPhysicsEngine(PhysicsEngine newEngine)
Set the current physics engine.static double
speed(double movement, double dt)
Replies the new velocity according to a previous velocity and a mouvement during a given time.
-
-
-
Method Detail
-
getPhysicsEngine
@Pure public static PhysicsEngine getPhysicsEngine()
Replies the current physics engine.- Returns:
- the current physics engine.
-
setPhysicsEngine
public static PhysicsEngine setPhysicsEngine(PhysicsEngine newEngine)
Set the current physics engine.If the given engine is
null
, the default physics engine is used (java implementation).- Parameters:
newEngine
- the current physics engine, ornull
for default engine.- Returns:
- previous physics engine.
-
motionNewtonLaw
@Pure public static double motionNewtonLaw(double speed, double acceleration, double dt)
Compute and replies a motion according to high school physics Newton's equations for motion.movement = speed * dt + 0.5 * acceleration * dt * dt
- Parameters:
speed
- is the current speed of the object.acceleration
- is the current acceleration of the object.dt
- is the time- Returns:
- a motion
-
motionNewtonLaw1D
@Pure public static double motionNewtonLaw1D(double velocity, double minSpeed, double maxSpeed, double acceleration, double minAcceleration, double maxAcceleration, double dt)
Compute and replies a motion according to high school physics Newton's equations for motion.This function allows to clamp acceleration and velocity.
clamped_acceleration = clamp(acceleration, minAcceleration, maxAcceleration)
new_velocity = velocity + 0.5 * clamped_acceleration * dt
clamped_velocity = clamp(new_velocity, minSpeed, maxSpeed)
motion = clamped_velocity * dt
- Parameters:
velocity
- is the current velocity of the object.minSpeed
- is the minimal speed allowed.maxSpeed
- is the maximal speed allowed.acceleration
- is the current acceleration of the object.minAcceleration
- is the minimal acceleration allowed.maxAcceleration
- is the maximal acceleration allowed. Length of this vector is the acceleration amount. Direction of this vector becomes movement direction.dt
- is the time.- Returns:
- the motion
- See Also:
- "http://en.wikibooks.org/wiki/High_School_Physics/Velocity"
-
motionNewtonLaw1D5
@Deprecated(since="16.0", forRemoval=true) @Pure public static void motionNewtonLaw1D5(Vector2D<?,?> velocity, double minSpeed, double maxSpeed, Vector2D<?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector2D<?,?> result)
Deprecated, for removal: This API element is subject to removal in a future version.Compute and replies a motion according to high school physics Newton's equations for motion.This function allows to clamp acceleration and velocity.
clamped_acceleration = clamp(acceleration, minAcceleration, maxAcceleration)
new_velocity = velocity + 0.5 * clamped_acceleration * dt
clamped_velocity = clamp(new_velocity, minSpeed, maxSpeed)
motion = clamped_velocity * dt
- Parameters:
velocity
- is the current velocity of the object. Norm of vector is speed in m/s for example.minSpeed
- is the minimal speed allowed.maxSpeed
- is the maximal speed allowed.acceleration
- is the current acceleration of the object. Norm of vector is acceleration amount in m/s2 for example.minAcceleration
- is the minimal acceleration allowed.maxAcceleration
- is the maximal acceleration allowed. Length of this vector is the acceleration amount. Direction of this vector becomes movement direction.dt
- is the time.result
- the motion.- See Also:
- "http://en.wikibooks.org/wiki/High_School_Physics/Velocity"
-
motionNewtonLaw1D5
@Pure public static void motionNewtonLaw1D5(Vector1D<?,?,?> velocity, double minSpeed, double maxSpeed, Vector1D<?,?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector1D<?,?,?> result)
Compute and replies a motion according to high school physics Newton's equations for motion.This function allows to clamp acceleration and velocity.
clamped_acceleration = clamp(acceleration, minAcceleration, maxAcceleration)
new_velocity = velocity + 0.5 * clamped_acceleration * dt
clamped_velocity = clamp(new_velocity, minSpeed, maxSpeed)
motion = clamped_velocity * dt
Caution: The resulting vector has the same segment as the provided vector.
- Parameters:
velocity
- is the current velocity of the object. Norm of vector is speed in m/s for example.minSpeed
- is the minimal speed allowed.maxSpeed
- is the maximal speed allowed.acceleration
- is the current acceleration of the object. Norm of vector is acceleration amount in m/s2 for example.minAcceleration
- is the minimal acceleration allowed.maxAcceleration
- is the maximal acceleration allowed. Length of this vector is the acceleration amount. Direction of this vector becomes movement direction.dt
- is the time.result
- the motion.- See Also:
- "http://en.wikibooks.org/wiki/High_School_Physics/Velocity"
-
motionNewtonLaw2D
@Pure public static void motionNewtonLaw2D(Vector2D<?,?> velocity, double minSpeed, double maxSpeed, Vector2D<?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector2D<?,?> result)
Compute and replies a motion according to high school physics Newton's equations for motion.This function allows to clamp acceleration and velocity.
clamped_acceleration = clamp(acceleration, minAcceleration, maxAcceleration)
new_velocity = velocity + 0.5 * clamped_acceleration * dt
clamped_velocity = clamp(new_velocity, minSpeed, maxSpeed)
motion = clamped_velocity * dt
- Parameters:
velocity
- is the current velocity of the object. Norm of vector is speed in m/s for example.minSpeed
- is the minimal speed allowed.maxSpeed
- is the maximal speed allowed.acceleration
- is the current acceleration of the object. Norm of vector is acceleration amount in m/s2 for example.minAcceleration
- is the minimal acceleration allowed.maxAcceleration
- is the maximal acceleration allowed. Length of this vector is the acceleration amount. Direction of this vector becomes movement direction.dt
- is the time.result
- the motion.- See Also:
- "http://en.wikibooks.org/wiki/High_School_Physics/Velocity"
-
motionNewtonLaw2D5
@Pure public static void motionNewtonLaw2D5(Vector3D<?,?> velocity, double minSpeed, double maxSpeed, Vector3D<?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector3D<?,?> result)
Compute and replies a motion according to high school physics Newton's equations for motion.This function allows to clamp acceleration and velocity.
clamped_acceleration = clamp(acceleration, minAcceleration, maxAcceleration)
new_velocity = velocity + 0.5 * clamped_acceleration * dt
clamped_velocity = clamp(new_velocity, minSpeed, maxSpeed)
motion = clamped_velocity * dt
- Parameters:
velocity
- is the current velocity of the object. Norm of vector is speed in m/s for example.minSpeed
- is the minimal speed allowed.maxSpeed
- is the maximal speed allowed.acceleration
- is the current acceleration of the object. Norm of vector is acceleration amount in m/s2 for example.minAcceleration
- is the minimal acceleration allowed.maxAcceleration
- is the maximal acceleration allowed. Length of this vector is the acceleration amount. Direction of this vector becomes movement direction.dt
- is the time.result
- the motion.- See Also:
- "http://en.wikibooks.org/wiki/High_School_Physics/Velocity"
-
motionNewtonLaw3D
@Pure public static void motionNewtonLaw3D(Vector3D<?,?> velocity, double minSpeed, double maxSpeed, Vector3D<?,?> acceleration, double minAcceleration, double maxAcceleration, double dt, Vector3D<?,?> result)
Compute and replies a motion according to high school physics Newton's equations for motion.This function allows to clamp acceleration and velocity.
clamped_acceleration = clamp(acceleration, minAcceleration, maxAcceleration)
new_velocity = velocity + 0.5 * clamped_acceleration * dt
clamped_velocity = clamp(new_velocity, minSpeed, maxSpeed)
motion = clamped_velocity * dt
- Parameters:
velocity
- is the current velocity of the object. Norm of vector is speed in m/s for example.minSpeed
- is the minimal speed allowed.maxSpeed
- is the maximal speed allowed.acceleration
- is the current acceleration of the object. Norm of vector is acceleration amount in m/s2 for example.minAcceleration
- is the minimal acceleration allowed.maxAcceleration
- is the maximal acceleration allowed. Length of this vector is the acceleration amount. Direction of this vector becomes movement direction.dt
- is the time.result
- the motion.- See Also:
- "http://en.wikibooks.org/wiki/High_School_Physics/Velocity"
-
motionNewtonEuler1Law
@Pure public static double motionNewtonEuler1Law(double speed, double dt)
Compute and replies a motion according to Newton-Euler-1 equations for motion.movement = speed * dt
- Parameters:
speed
- is the current speed of the object.dt
- is the time- Returns:
- a motion
-
motionNewtonEuler1Law1D
@Pure public static double motionNewtonEuler1Law1D(double velocity, double minSpeed, double maxSpeed, double dt)
Compute and replies a motion according to Newton-Euler-1 equations for motion.movement = clamp(velocity) * dt
- Parameters:
velocity
- is the current velocity of the object.minSpeed
- is the minimal speed allowed.maxSpeed
- is the maximal speed allowed.dt
- is the time- Returns:
- a motion
-
motionNewtonEuler1Law1D5
@Deprecated(since="16.0", forRemoval=true) @Pure public static void motionNewtonEuler1Law1D5(Vector2D<?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector2D<?,?> result)
Deprecated, for removal: This API element is subject to removal in a future version.Compute and replies a motion according to Newton-Euler-1 equations for motion.movement = clamp(velocity) * dt
- Parameters:
velocity
- is the current velocity of the object.minSpeed
- is the minimal speed allowed (clamped to 0 if negative).maxSpeed
- is the maximal speed allowed.dt
- is the timeresult
- a motion
-
motionNewtonEuler1Law1D5
@Pure public static void motionNewtonEuler1Law1D5(Vector1D<?,?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector1D<?,?,?> result)
Compute and replies a motion according to Newton-Euler-1 equations for motion.movement = clamp(velocity) * dt
Caution: The resulting vector has the same segment as the provided vector.
- Parameters:
velocity
- is the current velocity of the object.minSpeed
- is the minimal speed allowed (clamped to 0 if negative).maxSpeed
- is the maximal speed allowed.dt
- is the timeresult
- a motion
-
motionNewtonEuler1Law2D
@Pure public static void motionNewtonEuler1Law2D(Vector2D<?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector2D<?,?> result)
Compute and replies a motion according to Newton-Euler-1 equations for motion.movement = clamp(velocity) * dt
- Parameters:
velocity
- is the current velocity of the object.minSpeed
- is the minimal speed allowed (clamped to 0 if negative).maxSpeed
- is the maximal speed allowed.dt
- is the timeresult
- a motion
-
motionNewtonEuler1Law2D5
@Pure public static void motionNewtonEuler1Law2D5(Vector3D<?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector3D<?,?> result)
Compute and replies a motion according to Newton-Euler-1 equations for motion.movement = clamp(velocity) * dt
- Parameters:
velocity
- is the current velocity of the object.minSpeed
- is the minimal speed allowed (clamped to 0 if negative).maxSpeed
- is the maximal speed allowed.dt
- is the timeresult
- a motion
-
motionNewtonEuler1Law3D
@Pure public static void motionNewtonEuler1Law3D(Vector3D<?,?> velocity, double minSpeed, double maxSpeed, double dt, Vector3D<?,?> result)
Compute and replies a motion according to Newton-Euler-1 equations for motion.movement = clamp(velocity) * dt
- Parameters:
velocity
- is the current velocity of the object.minSpeed
- is the minimal speed allowed (clamped to 0 if negative).maxSpeed
- is the maximal speed allowed.dt
- is the timeresult
- a motion
-
speed
@Pure public static double speed(double movement, double dt)
Replies the new velocity according to a previous velocity and a mouvement during a given time.velocity = movement / dt
- Parameters:
movement
- is the movement distance.dt
- is the time- Returns:
- a new speed
-
acceleration
@Pure public static double acceleration(double previousSpeed, double currentSpeed, double dt)
Replies the new acceleration according to a previous velocity and a current velocity, and given time.(currentVelocity - previousVelocity) / dt
- Parameters:
previousSpeed
- is the previous speed of the object.currentSpeed
- is the current speed of the object.dt
- is the time- Returns:
- a new acceleration
-
-