twn_vec.h: add vec2_length(), remove legacy code

This commit is contained in:
veclavtalica 2025-01-24 04:28:09 +03:00
parent a20be2c523
commit e281ba593c

View File

@ -29,6 +29,10 @@ static inline Vec2 vec2_scale(Vec2 a, float s) {
return (Vec2) { a.x * s, a.y * 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) { static inline Vec3 vec3_add(Vec3 a, Vec3 b) {
return (Vec3) { a.x + b.x, a.y + b.y, a.z + b.z }; 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; 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), \ #define m_vec_add(p_any_vec0, p_any_vec1) (_Generic((p_any_vec0), \
Vec2: vec2_add, \ Vec2: vec2_add, \
Vec3: vec3_add \ Vec3: vec3_add \