Banjo API 0.0.1
C99 game development API
|
Topics | |
2D Physics |
Macros | |
#define | BJ_GRAVITATIONAL_CONSTANT_SI BJ_F(6.67430e-11) |
Functions | |
static bj_real | bj_galileo_position (bj_real position, bj_real velocity, bj_real acceleration, bj_real time) |
static bj_real | bj_galileo_velocity (bj_real velocity, bj_real acceleration, bj_real time) |
static bj_real | bj_newton_gravitation (bj_real m1, bj_real m2, bj_real r, bj_real g) |
static bj_real | bj_newton_plummer_gravitation (bj_real m1, bj_real m2, bj_real r, bj_real g, bj_real eps) |
Basic physics utilities (constant-acceleration kinematics, etc.)
This header provides small helpers for common physics operations. By default, quantities are interpreted in SI units (meters, seconds), but formulas are dimensionally homogeneous: results are correct for any consistent unit system (e.g., km and s; cm and s), provided all inputs use the same system.
Dimensionality uses the base dimensions L (length) and T (time). For example:
#define BJ_GRAVITATIONAL_CONSTANT_SI BJ_F(6.67430e-11) |
Newtonian constant of gravitation in SI units.
Defines the physical constant G = 6.67430 × 10⁻¹¹ m³·kg⁻¹·s⁻², expressed in the active bj_real precision type.
|
inlinestatic |
Galileo’s uniformly accelerated motion — position at time t.
Uses: x(t) = x0 + v0 * t + 0.5 * a * t^2
position | Initial position [L] |
velocity | Initial velocity [L T^-1] |
acceleration | Constant acceleration [L T^-2] |
time | Elapsed time [T] |
Galileo’s uniformly accelerated motion — velocity at time t.
Uses: v(t) = v0 + a * t
velocity | Initial velocity [L T^-1] |
acceleration | Constant acceleration [L T^-2] |
time | Elapsed time [T] |
Newton’s law of universal gravitation — force magnitude.
m1 | Mass of first body [M] |
m2 | Mass of second body [M] |
r | Separation distance [L] |
g | Gravitational constant G [L^3 M^-1 T^-2] |
|
inlinestatic |
Newtonian gravitation with Plummer softening — force magnitude.
m1 | Mass of first body [M] |
m2 | Mass of second body [M] |
r | Separation distance [L] |
g | Gravitational constant G [L^3 M^-1 T^-2] |
eps | Softening length ε [L] |