1 Math.euclideanDistance = function(a, b) { 2 let xd = (a.x - b.x), yd = (a.y - b.y); 3 return Math.sqrt(xd * xd + yd * yd); 4 }; 5 6 Math.angleRadians = function(a, b) { 7 return Math.atan2(b.y - a.y, b.x - a.x); 8 }; 9 10 Math.angleDegrees = function(a, b) { 11 return Math.angleRadians(a, b) * 180 / Math.PI; 12 }; 13 14 Math.midpoint = function(a, b) { 15 return { 16 x: (a.x + b.x) / 2, 17 y: (a.y + b.y) / 2, 18 }; 19 }; 20 Math.circupoint = function(origin, radius, radians) { 21 return { 22 x: origin.x + radius * Math.cos(radians), 23 y: origin.y + radius * Math.sin(radians), 24 }; 25 };