|
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
|
Double-precision 3D vector helpers for physics simulation. More...
#include <math.h>Go to the source code of this file.
Typedefs | |
| typedef double | dvec3[3] |
Functions | |
| static void | dvec3_zero (dvec3 dest) |
| static void | dvec3_copy (const dvec3 src, dvec3 dest) |
| static void | dvec3_set (dvec3 dest, double x_val, double y_val, double z_val) |
| static void | dvec3_add (const dvec3 a_vec, const dvec3 b_vec, dvec3 dest) |
| static void | dvec3_addto (dvec3 dest, const dvec3 b_vec) |
| static void | dvec3_sub (const dvec3 a_vec, const dvec3 b_vec, dvec3 dest) |
| static void | dvec3_subfrom (dvec3 dest, const dvec3 b_vec) |
| static void | dvec3_scale (const dvec3 v_vec, double scalar, dvec3 dest) |
| static void | dvec3_muladds (dvec3 dest, const dvec3 v_vec, double scalar) |
| static double | dvec3_dot (const dvec3 a_vec, const dvec3 b_vec) |
| static double | dvec3_norm2 (const dvec3 v_vec) |
| static double | dvec3_norm (const dvec3 v_vec) |
| static void | dvec3_normalize (dvec3 v_vec) |
Double-precision 3D vector helpers for physics simulation.
cglm (v0.9.x) only provides float-precision vec3 operations — there is no dvec3 type and no SIMD acceleration for vec3 (SSE/NEON are only used for vec4 and mat4, where 4-wide lanes map naturally to 128-bit registers).
These inline helpers mirror the cglm vec3 API (glm_vec3_*) but operate on plain double[3] arrays, giving the n-body simulation the numerical precision it needs without sacrificing readability.
Performance note: on 14 bodies the overhead of double vs float is negligible. Should the body count grow to hundreds, consider migrating to AVX double SIMD (2-wide __m128d or 4-wide __m256d).
| typedef double dvec3[3] |
A double-precision 3D vector stored as a plain array.
dest = a + b
dest += b (in-place accumulate).
dest += v * s (multiply-add, used in Verlet integration).
|
inlinestatic |
Length: |v|
|
inlinestatic |
Squared length: |v|²
|
inlinestatic |
Normalize v in-place. No-op if length is zero.
dest = v * s (uniform scale).
|
inlinestatic |
Set dest from three scalars.
dest = a - b
dest -= b (in-place subtract).
|
inlinestatic |
Set all components to zero: dest = {0, 0, 0}.