Banjo API 1.0.0-rc.2
Low-level C99 game development API
Loading...
Searching...
No Matches
physics_2d.h
Go to the documentation of this file.
1
43#ifndef BJ_PHYSICS_2D_H
44#define BJ_PHYSICS_2D_H
45
46#include <banjo/api.h>
47#include <banjo/math.h>
48#include <banjo/vec.h>
49
62 struct bj_vec2 position,
63 struct bj_vec2 velocity,
64 struct bj_vec2 acceleration,
65 bj_real time
66);
67
79 struct bj_vec2 velocity,
80 struct bj_vec2 acceleration,
81 bj_real time
82);
83
106struct bj_particle_2d;
107
118 struct bj_particle_2d* particle,
119 const struct bj_vec2 force
120);
121
132 struct bj_particle_2d* particle,
133 bj_real dt
134);
135
145 struct bj_particle_2d* particle,
147);
148
160 struct bj_particle_2d* BJ_RESTRICT particle_from,
161 const struct bj_particle_2d* BJ_RESTRICT particle_to,
162 const bj_real gravity_factor
163);
164
176 struct bj_particle_2d* BJ_RESTRICT particle_from,
177 const struct bj_particle_2d* BJ_RESTRICT particle_to,
178 const bj_real gravity_factor,
179 const bj_real epsilon
180);
181
192 struct bj_particle_2d* particle,
193 bj_real k1,
194 bj_real k2
195);
196
208 const struct bj_vec2 vel,
209 const bj_real k1,
210 const bj_real k2
211);
212
224 struct bj_vec2 vel,
225 const bj_real k1,
226 const bj_real k2
227);
228
232
254struct bj_angular_2d;
255
263 struct bj_angular_2d* angular,
265);
266
276 struct bj_angular_2d* angular,
277 bj_real delta_time
278);
279
292struct bj_rigid_body_2d;
293
303 struct bj_rigid_body_2d* body,
304 const struct bj_vec2 force
305);
306
316 struct bj_rigid_body_2d* body,
317 bj_real delta_time
318);
319
323
324#endif /* BJ_PHYSICS_2D_H */
General-purpose definitions for Banjo API.
#define BANJO_EXPORT
Definition api.h:163
#define BJ_RESTRICT
BJ_RESTRICT expands to the appropriate restrict qualifier per toolchain.
Definition api.h:207
float bj_real
Selected real type for float configuration.
Definition math.h:76
2D vector of bj_real components.
Definition vec.h:51
struct bj_vec2 position
Definition physics_2d.h:99
bj_real torque
Definition physics_2d.h:250
bj_real damping
Definition physics_2d.h:103
struct bj_vec2 acceleration
Definition physics_2d.h:101
bj_real inverse_inertia
Definition physics_2d.h:252
struct bj_vec2 velocity
Definition physics_2d.h:100
bj_real velocity
Definition physics_2d.h:248
struct bj_particle_2d particle
Definition physics_2d.h:289
struct bj_angular_2d angular
Definition physics_2d.h:290
bj_real value
Definition physics_2d.h:247
struct bj_vec2 forces
Definition physics_2d.h:102
bj_real acceleration
Definition physics_2d.h:249
bj_real inverse_mass
Definition physics_2d.h:104
bj_real damping
Definition physics_2d.h:251
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.
Definition physics_2d.h:98
Rigid body with translational and angular components.
Definition physics_2d.h:288
C99 math shim with bj_real precision type and scalar utilities.
bj_vec2 gravity
Fixed-size vector types (2D, 3D, 4D) and inline operations.