jtmm2/src/vec.c

24 lines
298 B
C

#include "vec.h"
#include <math.h>
struct VecF
vecf(struct Vec v)
{
return (struct VecF){v.x, v.y};
}
struct Vec
vec(struct VecF v)
{
return (struct Vec){v.x, v.y};
}
struct VecF
normalize(struct VecF v)
{
const float len = sqrt(v.x * v.x + v.y * v.y);
v.x /= len;
v.y /= len;
return v;
}