Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
physics_2d.h
Go to the documentation of this file.
1
23#ifndef BJ_PHYSICS_2D_H
24#define BJ_PHYSICS_2D_H
25
26#include <banjo/api.h>
27#include <banjo/math.h>
28#include <banjo/vec.h>
29
42 struct bj_vec2 position,
43 struct bj_vec2 velocity,
44 struct bj_vec2 acceleration,
45 bj_real time
46);
47
59 struct bj_vec2 velocity,
60 struct bj_vec2 acceleration,
61 bj_real time
62);
63
86struct bj_particle_2d;
87
98 struct bj_particle_2d* particle,
99 const struct bj_vec2 force
100);
101
112 struct bj_particle_2d* particle,
113 bj_real dt
114);
115
125 struct bj_particle_2d* particle,
126 bj_real gravity
127);
128
140 struct bj_particle_2d* BJ_RESTRICT particle_from,
141 const struct bj_particle_2d* BJ_RESTRICT particle_to,
142 const bj_real gravity_factor
143);
144
156 struct bj_particle_2d* BJ_RESTRICT particle_from,
157 const struct bj_particle_2d* BJ_RESTRICT particle_to,
158 const bj_real gravity_factor,
159 const bj_real epsilon
160);
161
172 struct bj_particle_2d* particle,
173 bj_real k1,
174 bj_real k2
175);
176
188 const struct bj_vec2 vel,
189 const bj_real k1,
190 const bj_real k2
191);
192
204 struct bj_vec2 vel,
205 const bj_real k1,
206 const bj_real k2
207);
208
212
234struct bj_angular_2d;
235
243 struct bj_angular_2d* angular,
245);
246
256 struct bj_angular_2d* angular,
257 double delta_time
258);
259
272struct bj_rigid_body_2d;
273
283 struct bj_rigid_body_2d* body,
284 const struct bj_vec2 force
285);
286
296 struct bj_rigid_body_2d* body,
297 double delta_time
298);
299
303
304#endif /* BJ_PHYSICS_2D_H */
General-purpose definitions for Banjo API.
#define BANJO_EXPORT
Definition api.h:155
#define BJ_RESTRICT
BJ_RESTRICT expands to the appropriate restrict qualifier per toolchain.
Definition api.h:199
float bj_real
Selected real type for float configuration.
Definition math.h:51
struct bj_vec2: 2D vector of bj_real values.
Definition vec.h:26
struct bj_vec2 position
Definition physics_2d.h:79
bj_real torque
Definition physics_2d.h:230
bj_real damping
Definition physics_2d.h:83
struct bj_vec2 acceleration
Definition physics_2d.h:81
bj_real inverse_inertia
Definition physics_2d.h:232
struct bj_vec2 velocity
Definition physics_2d.h:80
bj_real velocity
Definition physics_2d.h:228
struct bj_particle_2d particle
Definition physics_2d.h:269
struct bj_angular_2d angular
Definition physics_2d.h:270
bj_real value
Definition physics_2d.h:227
struct bj_vec2 forces
Definition physics_2d.h:82
bj_real acceleration
Definition physics_2d.h:229
bj_real inverse_mass
Definition physics_2d.h:84
bj_real damping
Definition physics_2d.h:231
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.
void bj_step_rigid_body_2d(struct bj_rigid_body_2d *body, double delta_time)
Step rigid body linear and angular states.
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.
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_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.
void bj_step_angular_2d(struct bj_angular_2d *angular, double delta_time)
Semi-implicit Euler step for angular motion.
Angular.
Definition physics_2d.h:226
2D point mass state and physical properties.
Definition physics_2d.h:78
Rigid body with translational and angular components.
Definition physics_2d.h:268
C99 math shim with bj_real precision type and scalar utilities.
vector manipulation API