|
JSim 2026.06.01-p(1)
|
Simulated rigid body with translational/angular dynamics and optional aero metadata. More...
#include <rigid_body.hpp>
Classes | |
| struct | AerodynamicGeometry |
| Geometric metadata used to estimate drag reference area. More... | |
Public Types | |
| enum class | CylinderAxis { kX , kY , kZ } |
| Principal axis selection for cylindrical aerodynamic geometry. More... | |
Public Member Functions | |
| RigidBody (double mass_kg=1.0) | |
| Constructs a rigid body with a sanitized positive mass. | |
| double | massKg () const |
| Returns mass in kilograms. | |
| double | inverseMass () const |
| Returns inverse mass in 1/kg. | |
| void | setMassKg (double mass_kg) |
| Sets mass in kilograms. | |
| const Vector3 & | position () const |
| Returns world position in meters. | |
| void | setPosition (const Vector3 &position_m) |
| Sets world-space position in meters. | |
| void | setPosition (double x_m, double y_m, double z_m) |
| Sets world-space position in meters from scalar components. | |
| void | position (double *x_m, double *y_m, double *z_m) const |
| Gets world-space position in meters via scalar output pointers. | |
| const Quaternion & | orientation () const |
| Returns body orientation as a unit quaternion. | |
| void | setOrientation (const Quaternion &orientation) |
| Sets body orientation quaternion. | |
| const Vector3 & | linearVelocity () const |
| Returns world linear velocity in meters per second. | |
| void | setLinearVelocity (const Vector3 &velocity_mps) |
| Sets world linear velocity in meters per second. | |
| void | setLinearVelocity (double vx_mps, double vy_mps, double vz_mps) |
| Sets world linear velocity in meters per second from scalars. | |
| void | linearVelocity (double *vx_mps, double *vy_mps, double *vz_mps) const |
| Gets world linear velocity in meters per second via pointers. | |
| const Vector3 & | angularVelocity () const |
| Returns world angular velocity in radians per second. | |
| void | setAngularVelocity (const Vector3 &angular_velocity_radps) |
| Sets world angular velocity in radians per second. | |
| void | setAngularVelocity (double wx_radps, double wy_radps, double wz_radps) |
| Sets world angular velocity in radians per second from scalars. | |
| void | angularVelocity (double *wx_radps, double *wy_radps, double *wz_radps) const |
| Gets world angular velocity in radians per second via pointers. | |
| const Matrix3 & | bodyInertiaTensor () const |
| Returns inertia tensor in body frame. | |
| void | setBodyInertiaTensor (const Matrix3 &inertia) |
| Sets body-frame inertia tensor and cached inverse tensor. | |
| BodyFlags & | flags () |
| Mutable access to runtime body flags. | |
| const BodyFlags & | flags () const |
| Const access to runtime body flags. | |
| void | setMaterial (const Material &material) |
| Sets optional physical material properties. | |
| const Material * | material () const |
| Gets material if configured, otherwise returns null. | |
| void | setMaterialId (std::int32_t material_id) |
| Sets numeric material identifier used by world interaction tables. | |
| std::int32_t | materialId () const |
| Gets numeric material identifier used by world interaction tables. | |
| void | setCollisionLayer (std::uint32_t layer_bits) |
| Sets broad-phase collision layer bits for this body. | |
| std::uint32_t | collisionLayer () const |
| Gets broad-phase collision layer bits. | |
| void | setCollisionMask (std::uint32_t mask_bits) |
| Sets broad-phase collision mask bits for this body. | |
| std::uint32_t | collisionMask () const |
| Gets broad-phase collision mask bits. | |
| void | setAerodynamicGeometry (const AerodynamicGeometry &geometry) |
| Sets optional aerodynamic geometry metadata. | |
| const AerodynamicGeometry * | aerodynamicGeometry () const |
| Gets aerodynamic geometry if configured, otherwise returns null. | |
| void | setCylinderAxisLocal (CylinderAxis axis) |
| Sets cylinder axis in local coordinates via canonical enum axis. | |
| void | setCylinderAxisWorld (const Vector3 &axis_world) |
| Sets cylinder axis from world-space direction. | |
| void | setCylinderAxisWorld (double x, double y, double z) |
| Sets cylinder axis from world-space scalar direction components. | |
| double | dragReferenceAreaM2 (const Vector3 &velocity_world) const |
| Computes effective drag reference area for current geometry and motion direction. | |
| void | applyForce (const Vector3 &force_n) |
| Adds force at center of mass in newtons. | |
| void | applyForce (double fx_n, double fy_n, double fz_n) |
| Adds force at center of mass in newtons from scalar components. | |
| void | applyForceAtPoint (const Vector3 &force_n, const Vector3 &world_point_m) |
| Adds force at world-space point, accumulating both force and torque. | |
| void | applyForceAtPoint (double fx_n, double fy_n, double fz_n, double px_m, double py_m, double pz_m) |
| Adds force at world-space point from scalar components. | |
| void | clearAccumulators () |
| Clears accumulated force and torque buffers. | |
| void | integrate (double dt_s, IntegrationMethod method, const Vector3 &gravity_mps2, double linear_damping_per_s, double angular_damping_per_s) |
| Advances translational and rotational state by one fixed timestep. | |
Simulated rigid body with translational/angular dynamics and optional aero metadata.
This type stores canonical rigid-body state (pose, linear velocity, angular velocity, mass, inertia) and supports force/torque accumulation followed by fixed-step integration.
Key behavior:
|
strong |
|
inlineexplicit |
Constructs a rigid body with a sanitized positive mass.
| mass_kg | Body mass in kilograms. |
|
inline |
Gets aerodynamic geometry if configured, otherwise returns null.
|
inline |
Returns world angular velocity in radians per second.
|
inline |
Gets world angular velocity in radians per second via pointers.
| wx_radps | Optional output pointer for world-space angular velocity x. |
| wy_radps | Optional output pointer for world-space angular velocity y. |
| wz_radps | Optional output pointer for world-space angular velocity z. |
|
inline |
Adds force at center of mass in newtons.
|
inline |
Adds force at center of mass in newtons from scalar components.
| fx_n | World-space x force in newtons. |
| fy_n | World-space y force in newtons. |
| fz_n | World-space z force in newtons. |
|
inline |
Adds force at world-space point, accumulating both force and torque.
| force_n | Applied force in newtons. |
| world_point_m | Application point in world meters. |
|
inline |
Adds force at world-space point from scalar components.
| fx_n | World-space x force in newtons. |
| fy_n | World-space y force in newtons. |
| fz_n | World-space z force in newtons. |
| px_m | World-space x application point in meters. |
| py_m | World-space y application point in meters. |
| pz_m | World-space z application point in meters. |
|
inline |
Returns inertia tensor in body frame.
|
inline |
Clears accumulated force and torque buffers.
|
inline |
Gets broad-phase collision layer bits.
|
inline |
Gets broad-phase collision mask bits.
|
inline |
Computes effective drag reference area for current geometry and motion direction.
| velocity_world | World-space velocity vector used to infer projected area. |
Behavior by geometry mode:
For zero velocity vectors, a stable fallback direction is used to avoid NaN behavior during normalization.
|
inline |
Mutable access to runtime body flags.
|
inline |
Const access to runtime body flags.
|
inline |
Advances translational and rotational state by one fixed timestep.
| dt_s | Timestep duration in seconds. |
| method | Translation integration strategy. |
| gravity_mps2 | World-space gravity acceleration in m/s^2. |
| linear_damping_per_s | Linear damping coefficient in 1/s. |
| angular_damping_per_s | Angular damping coefficient in 1/s. |
Integration sequence:
|
inline |
Returns inverse mass in 1/kg.
|
inline |
Returns world linear velocity in meters per second.
|
inline |
Gets world linear velocity in meters per second via pointers.
| vx_mps | Optional output pointer for world-space x velocity in m/s. |
| vy_mps | Optional output pointer for world-space y velocity in m/s. |
| vz_mps | Optional output pointer for world-space z velocity in m/s. |
|
inline |
Returns mass in kilograms.
|
inline |
Gets material if configured, otherwise returns null.
|
inline |
Gets numeric material identifier used by world interaction tables.
|
inline |
Returns body orientation as a unit quaternion.
|
inline |
Returns world position in meters.
|
inline |
Gets world-space position in meters via scalar output pointers.
| x_m | Optional output pointer for world-space x position in meters. |
| y_m | Optional output pointer for world-space y position in meters. |
| z_m | Optional output pointer for world-space z position in meters. |
|
inline |
Sets optional aerodynamic geometry metadata.
|
inline |
Sets world angular velocity in radians per second.
| angular_velocity_radps | World-space angular velocity in radians per second. |
|
inline |
Sets world angular velocity in radians per second from scalars.
| wx_radps | World-space angular velocity x in radians per second. |
| wy_radps | World-space angular velocity y in radians per second. |
| wz_radps | World-space angular velocity z in radians per second. |
|
inline |
Sets body-frame inertia tensor and cached inverse tensor.
|
inline |
Sets broad-phase collision layer bits for this body.
| layer_bits | Layer membership bitset. |
|
inline |
Sets broad-phase collision mask bits for this body.
| mask_bits | Interaction acceptance bitset. |
|
inline |
Sets cylinder axis in local coordinates via canonical enum axis.
|
inline |
Sets cylinder axis from world-space direction.
| axis_world | World-space direction to convert into local body space. |
The provided axis is transformed into local body space and normalized. Zero-length input falls back to local +Z.
|
inline |
Sets cylinder axis from world-space scalar direction components.
| x | World-space x direction component. |
| y | World-space y direction component. |
| z | World-space z direction component. |
|
inline |
Sets world linear velocity in meters per second.
| velocity_mps | World-space linear velocity in meters per second. |
|
inline |
Sets world linear velocity in meters per second from scalars.
| vx_mps | World-space x velocity in meters per second. |
| vy_mps | World-space y velocity in meters per second. |
| vz_mps | World-space z velocity in meters per second. |
|
inline |
Sets mass in kilograms.
|
inline |
Sets optional physical material properties.
|
inline |
Sets numeric material identifier used by world interaction tables.
| material_id | Application-defined material id. |
|
inline |
Sets body orientation quaternion.
| orientation | New world-space body orientation quaternion. |
|
inline |
Sets world-space position in meters.
| position_m | World-space position in meters. |
|
inline |
Sets world-space position in meters from scalar components.
| x_m | World-space x position in meters. |
| y_m | World-space y position in meters. |
| z_m | World-space z position in meters. |