# HG changeset patch # User Mike Becker # Date 1753210250 -7200 # Node ID 2ead0699ce77b10e810c8353fade3cad3b492842 # Parent 4b3c974eab44366db0c896a13492d86a3d106c8a add more vector arithmetic functions diff -r 4b3c974eab44 -r 2ead0699ce77 src/ascension/datatypes.h --- a/src/ascension/datatypes.h Mon Jul 21 21:28:34 2025 +0200 +++ b/src/ascension/datatypes.h Tue Jul 22 20:50:50 2025 +0200 @@ -354,12 +354,38 @@ return v.x*v.x + v.y*v.y + v.z*v.z; } +static inline asc_vec2i asc_vec2i_sub(asc_vec2i a, asc_vec2i b) { + return ASC_VEC2I(a.x-b.x, a.y-b.y); +} + +static inline asc_vec2u asc_vec2u_sub(asc_vec2u a, asc_vec2u b) { + // this may overflow - responsibility lies with the caller + return ASC_VEC2U(a.x-b.x, a.y-b.y); +} + static inline asc_vec2f asc_vec2f_sub(asc_vec2f a, asc_vec2f b) { return ASC_VEC2F(a.x-b.x, a.y-b.y); } -// TODO: add sub-functions for other types -// TODO: add add-functions +static inline asc_vec3f asc_vec3f_sub(asc_vec3f a, asc_vec3f b) { + return ASC_VEC3F(a.x-b.x, a.y-b.y, a.z-b.z); +} + +static inline asc_vec2i asc_vec2i_add(asc_vec2i a, asc_vec2i b) { + return ASC_VEC2I(a.x+b.x, a.y+b.y); +} + +static inline asc_vec2u asc_vec2u_add(asc_vec2u a, asc_vec2u b) { + return ASC_VEC2U(a.x+b.x, a.y+b.y); +} + +static inline asc_vec2f asc_vec2f_add(asc_vec2f a, asc_vec2f b) { + return ASC_VEC2F(a.x+b.x, a.y+b.y); +} + +static inline asc_vec3f asc_vec3f_add(asc_vec3f a, asc_vec3f b) { + return ASC_VEC3F(a.x+b.x, a.y+b.y, a.z+b.z); +} // -------------------------------------------------------------------------- // Matrix Functions