normalize static method

void normalize(
  1. Vec2D result,
  2. Vec2D a
)

Implementation

static void normalize(Vec2D result, Vec2D a) {
  double x = a[0];
  double y = a[1];
  double len = x * x + y * y;
  if (len > 0.0) {
    len = 1.0 / sqrt(len);
    result[0] = a[0] * len;
    result[1] = a[1] * len;
  }
}