code: function unit_vector_angle(ux, uy, vx, vy) {
    var sign = (ux * vy - uy * vx < 0) ? -1 : 1;
    var dot  = ux * vx + uy * vy;
  
    // Add this to work with arbitrary vectors:
    // dot /= Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy);
  
    // rounding errors, e.g. -1.0000000000000002 can screw up this
    if (dot >  1.0) { dot =  1.0; }
    if (dot < -1.0) { dot = -1.0; }
  
    return sign * Math.acos(dot);
  }
docs: Calculate an angle between two unit vectors  Since we measure angle between radii of circular arcs, we can use simplified math (without length normalization)