JSFiddle - React, Tailwind, and code Playground
JavaScript
function getMidPoint( /*int*/ x, /*int*/ y, /*int*/ width, /*int*/ height, /*int*/ angle )
{
width = width/2;
height = height/2
var dist = Math.sqrt( (Math.pow(width,2)) + (Math.pow(height,2)) );
var degtorad = Math.PI/180;
x += Math.cos(degtorad * (45+angle)) * dist;
y += Math.sin(degtorad * (45+angle)) * dist;
return {px: x, py: y};
}
var p = getMidPoint(50,90,200,300,0);
var p2 = getMidPoint(10,500,600,100,0);
alert("p1: "+p.px+", "+p.py); // Should be 150,240 right?
alert("p2: "+p2.px+", "+p2.py); // Should be 310,550 right?