12 Vec2f vec(float x, float y)
22 Vec2f vec_scala_mult(Vec2f v, float scalar)
32 Vec2f vec_from_polar(float arg, float mag)
34 return vec_scala_mult(
35 vec(cosf(arg), sinf(arg)),
40 Vec2f vec_from_ps(Vec2f p1, Vec2f p2)
50 float vec_arg(Vec2f v)
52 return atan2f(v.y, v.x);
56 float vec_mag(Vec2f v)
58 return sqrtf(v.x * v.x + v.y * v.y);
62 Vec2f vec_sum(Vec2f v1, Vec2f v2)
72 Vec2f vec_sub(Vec2f v1, Vec2f v2)
82 Vec2f vec_neg(Vec2f v)
93 float vec_length(Vec2f v)
95 return sqrtf(v.x * v.x + v.y * v.y);
99 void vec_add(Vec2f *v1, Vec2f v2)
106 Vec2f vec_entry_mult(Vec2f v1, Vec2f v2)
117 Vec2f vec_entry_div(Vec2f v1, Vec2f v2)
128 float rad_to_deg(float a)
134 Vec2f vec_norm(Vec2f v)
136 // TODO(#657): math/point/vec_norm: using vec_length is too expensive
137 // It involves multiplication and sqrt. We can just check if its components are close to 0.0f.
139 const float l = vec_length(v);
142 return vec(0.0f, 0.0f);
145 return vec(v.x / l, v.y / l);
149 float vec_sqr_norm(Vec2f v)
151 return v.x * v.x + v.y * v.y;
154 #define vec_scale vec_scala_mult
161 Vec2i vec2i(int x, int y)