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 BJ_ARRAY (bj_real, 2, out),
43 BJ_CONST_ARRAY(bj_real, 2, position),
44 BJ_CONST_ARRAY(bj_real, 2, velocity),
45 BJ_CONST_ARRAY(bj_real, 2, acceleration),
46 bj_real time
47);
48
60 BJ_ARRAY (bj_real, 2, out),
61 BJ_CONST_ARRAY(bj_real, 2, velocity),
62 BJ_CONST_ARRAY(bj_real, 2, acceleration),
63 bj_real time
64);
65
89
100 bj_particle_2d* p_particle,
101 const bj_vec2 force
102);
103
114 bj_particle_2d* p_particle,
115 bj_real dt
116);
117
127 bj_particle_2d* p_particle,
128 bj_real gravity
129);
130
142 bj_particle_2d* BJ_RESTRICT p_particle_from,
143 const bj_particle_2d* BJ_RESTRICT p_particle_to,
144 const bj_real gravity_factor
145);
146
158 bj_particle_2d* BJ_RESTRICT p_particle_from,
159 const bj_particle_2d* BJ_RESTRICT p_particle_to,
160 const bj_real gravity_factor,
161 const bj_real epsilon
162);
163
174 bj_particle_2d* p_particle,
175 bj_real k1,
176 bj_real k2
177);
178
190 const bj_vec2 vel,
191 const bj_real k1,
192 const bj_real k2
193);
194
208 BJ_ARRAY (bj_real, 2, result),
209 BJ_CONST_ARRAY(bj_real, 2, vel),
210 const bj_real k1,
211 const bj_real k2
212);
213
217
240
248 bj_angular_2d* angular,
250);
251
261 bj_angular_2d* angular,
262 double delta_time
263);
264
278
288 bj_rigid_body_2d* body,
289 const bj_vec2 force
290);
291
301 bj_rigid_body_2d* body,
302 double delta_time
303);
304
308
309#endif /* BJ_PHYSICS_2D_H */
General-purpose definitions for Banjo API.
#define BANJO_EXPORT
Definition api.h:139
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:276
#define BJ_CONST_ARRAY(T, n, name)
Definition api.h:224
#define BJ_RESTRICT
BJ_RESTRICT expands to the appropriate restrict qualifier per toolchain.
Definition api.h:183
#define BJ_ARRAY(T, n, name)
Definition api.h:225
bj_real bj_vec2[2]
bj_vec2: 2D vector of bj_real values.
Definition vec.h:27
float bj_real
Selected real type for float configuration.
Definition math.h:51
bj_vec2 velocity
Definition physics_2d.h:82
bj_real value
Definition physics_2d.h:232
bj_real torque
Definition physics_2d.h:235
bj_real inverse_mass
Definition physics_2d.h:86
bj_real acceleration
Definition physics_2d.h:234
bj_real velocity
Definition physics_2d.h:233
bj_real damping
Definition physics_2d.h:85
bj_vec2 position
Definition physics_2d.h:81
struct bj_angular_2d_t angular
Definition physics_2d.h:275
bj_vec2 forces
Definition physics_2d.h:84
bj_vec2 acceleration
Definition physics_2d.h:83
bj_real inverse_inertia
Definition physics_2d.h:237
struct bj_particle_2d_t particle
Definition physics_2d.h:274
bj_real damping
Definition physics_2d.h:236
void bj_apply_angular_torque_2d(bj_angular_2d *angular, bj_real torque)
Add torque to the angular accumulator.
void bj_apply_point_gravity_2d(bj_particle_2d *restrict p_particle_from, const bj_particle_2d *restrict p_particle_to, const bj_real gravity_factor)
Apply point gravity from one particle to another.
void bj_step_rigid_body_2d(bj_rigid_body_2d *body, double delta_time)
Step rigid body linear and angular states.
void bj_apply_gravity_2d(bj_particle_2d *p_particle, bj_real gravity)
Apply constant downward gravity in world space to a particle.
void bj_apply_particle_force_2d(bj_particle_2d *p_particle, const bj_vec2 force)
Add a force to a particle's accumulator.
void bj_step_particle_2d(bj_particle_2d *p_particle, bj_real dt)
Semi-implicit Euler step for a particle.
void bj_apply_rigidbody_force_2d(bj_rigid_body_2d *body, const bj_vec2 force)
Apply a world-space force at the center of mass.
struct bj_rigid_body_2d_t bj_rigid_body_2d
Definition physics_2d.h:277
bj_bool bj_compute_particle_drag_force_2d(bj_real result[restrict static(2)], const bj_real vel[restrict static(2)], const bj_real k1, const bj_real k2)
Compute drag force for a velocity.
struct bj_particle_2d_t bj_particle_2d
Definition physics_2d.h:88
void bj_compute_kinematics_velocity_2d(bj_real out[restrict static(2)], const bj_real velocity[restrict static(2)], const bj_real acceleration[restrict static(2)], bj_real time)
Integrate constant-acceleration 2D kinematics: velocity at time t.
void bj_compute_kinematics_2d(bj_real out[restrict static(2)], const bj_real position[restrict static(2)], const bj_real velocity[restrict static(2)], const bj_real acceleration[restrict static(2)], bj_real time)
Integrate constant-acceleration 2D kinematics: position at time t.
void bj_step_angular_2d(bj_angular_2d *angular, double delta_time)
Semi-implicit Euler step for angular motion.
struct bj_angular_2d_t bj_angular_2d
Definition physics_2d.h:239
void bj_apply_point_gravity_softened_2d(bj_particle_2d *restrict p_particle_from, const bj_particle_2d *restrict p_particle_to, const bj_real gravity_factor, const bj_real epsilon)
Apply softened point gravity to avoid singularities at small r.
bj_real bj_compute_particle_drag_coefficient_2d(const bj_vec2 vel, const bj_real k1, const bj_real k2)
Return scalar drag coefficient for a velocity.
void bj_apply_drag_2d(bj_particle_2d *p_particle, bj_real k1, bj_real k2)
Apply quadratic + linear drag to a particle's accumulator.
Angular.
Definition physics_2d.h:231
2D point mass state and physical properties.
Definition physics_2d.h:80
Rigid body with translational and angular components.
Definition physics_2d.h:273
C99 math shim with bj_real precision type and scalar utilities.
vector manipulation API