13 Vec vec(float x, float y)
23 Vec vec_scala_mult(Vec v, float scalar)
33 Vec vec_from_polar(float arg, float mag)
35 return vec_scala_mult(
36 vec(cosf(arg), sinf(arg)),
41 Vec vec_from_ps(Point p1, Point p2)
53 return atan2f(v.y, v.x);
59 return sqrtf(v.x * v.x + v.y * v.y);
63 Vec vec_sum(Vec v1, Vec v2)
73 Vec vec_sub(Vec v1, Vec v2)
94 float vec_length(Vec v)
96 return sqrtf(v.x * v.x + v.y * v.y);
100 void vec_add(Vec *v1, Vec v2)
107 Vec vec_entry_mult(Vec v1, Vec v2)
118 Vec vec_entry_div(Vec v1, Vec v2)
129 float rad_to_deg(float a)
137 // TODO(#657): math/point/vec_norm: using vec_length is too expensive
138 // It involves multiplication and sqrt. We can just check if its components are close to 0.0f.
140 const float l = vec_length(v);
143 return vec(0.0f, 0.0f);
146 return vec(v.x / l, v.y / l);
150 float vec_sqr_norm(Vec v)
152 return v.x * v.x + v.y * v.y;
155 #define vec_scale vec_scala_mult