This function is identical to vector_abs but it returns the squared
distance instead. The advantage of this function is that the one
square root calculation canb e omitted. If the actual distance is not
important, this function is faster than the one which returns the
absolute distance.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
return sqrt(a->x * a->x + a->y * a->y);
}
+static inline double vector_abs_squared(const struct vector *a)
+{
+ return a->x * a->x + a->y * a->y;
+}
+
static inline void vector_scale(const struct vector *a, const double b,
struct vector *res)
{