svgAngle method

dynamic svgAngle(
  1. dynamic ux,
  2. dynamic uy,
  3. dynamic vx,
  4. dynamic vy,
)

Implementation

svgAngle(ux, uy, vx, vy) {
  var dot = ux * vx + uy * vy;
  var len = Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy);
  var ang = Math.acos(Math.max(
      -1,
      Math.min(
          1,
          dot /
              len))); // floating point precision, slightly over values appear
  if ((ux * vy - uy * vx) < 0) ang = -ang;
  return ang;
}