normalize static method

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

Implementation

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