diff --git a/include/twn_vec.h b/include/twn_vec.h index 2158954..43ade04 100644 --- a/include/twn_vec.h +++ b/include/twn_vec.h @@ -29,6 +29,10 @@ static inline Vec2 vec2_scale(Vec2 a, float s) { return (Vec2) { a.x * s, a.y * s }; } +static inline float vec2_length(Vec2 a) { + return sqrtf(a.x * a.x + a.y * a.y); +} + static inline Vec3 vec3_add(Vec3 a, Vec3 b) { return (Vec3) { a.x + b.x, a.y + b.y, a.z + b.z }; } @@ -98,10 +102,8 @@ static inline Vec3 vec3_rotate(Vec3 v, float angle, Vec3 axis) { return v; } -#define m_vec2_from(p_any_vec2) (_Generic((p_any_vec2), \ - Vec2i: vec2_from_vec2i, \ - )(p_any_vec2)) +/* TODO: remove. */ #define m_vec_add(p_any_vec0, p_any_vec1) (_Generic((p_any_vec0), \ Vec2: vec2_add, \ Vec3: vec3_add \