43#ifndef BJ_PHYSICS_2D_H
44#define BJ_PHYSICS_2D_H
General-purpose definitions for Banjo API.
#define BJ_RESTRICT
BJ_RESTRICT expands to the appropriate restrict qualifier per toolchain.
float bj_real
Selected real type for float configuration.
2D vector of bj_real components.
struct bj_vec2 acceleration
struct bj_particle_2d particle
struct bj_angular_2d angular
void bj_apply_gravity_2d(struct bj_particle_2d *particle, bj_real gravity)
Apply constant downward gravity in world space to a particle.
void bj_apply_angular_torque_2d(struct bj_angular_2d *angular, bj_real torque)
Add torque to the angular accumulator.
void bj_step_particle_2d(struct bj_particle_2d *particle, bj_real dt)
Semi-implicit Euler step for a particle.
struct bj_vec2 bj_compute_kinematics_velocity_2d(struct bj_vec2 velocity, struct bj_vec2 acceleration, bj_real time)
Integrate constant-acceleration 2D kinematics: velocity at time t.
void bj_apply_point_gravity_softened_2d(struct bj_particle_2d *restrict particle_from, const struct bj_particle_2d *restrict particle_to, const bj_real gravity_factor, const bj_real epsilon)
Apply softened point gravity to avoid singularities at small r.
void bj_apply_drag_2d(struct bj_particle_2d *particle, bj_real k1, bj_real k2)
Apply quadratic + linear drag to a particle's accumulator.
void bj_step_rigid_body_2d(struct bj_rigid_body_2d *body, bj_real delta_time)
Step rigid body linear and angular states.
struct bj_vec2 bj_compute_kinematics_2d(struct bj_vec2 position, struct bj_vec2 velocity, struct bj_vec2 acceleration, bj_real time)
Integrate constant-acceleration 2D kinematics: position at time t.
void bj_step_angular_2d(struct bj_angular_2d *angular, bj_real delta_time)
Semi-implicit Euler step for angular motion.
void bj_apply_particle_force_2d(struct bj_particle_2d *particle, const struct bj_vec2 force)
Add a force to a particle's accumulator.
struct bj_vec2 bj_compute_particle_drag_force_2d(struct bj_vec2 vel, const bj_real k1, const bj_real k2)
Compute drag force for a velocity.
void bj_apply_rigidbody_force_2d(struct bj_rigid_body_2d *body, const struct bj_vec2 force)
Apply a world-space force at the center of mass.
bj_real bj_compute_particle_drag_coefficient_2d(const struct bj_vec2 vel, const bj_real k1, const bj_real k2)
Return scalar drag coefficient for a velocity.
void bj_apply_point_gravity_2d(struct bj_particle_2d *restrict particle_from, const struct bj_particle_2d *restrict particle_to, const bj_real gravity_factor)
Apply point gravity from one particle to another.
2D point mass state and physical properties.
Rigid body with translational and angular components.
C99 math shim with bj_real precision type and scalar utilities.
Fixed-size vector types (2D, 3D, 4D) and inline operations.