const canvasEl = document.querySelector('canvas');
const middle = { x: canvasEl.width/2, y: canvasEl.height /2 }
canvasEl.addEventListener(`pointermove`, event => {
const cursor = {
x: event.offsetX,
y: event.offsetY
}
const a = G.Points.angleRadian(middle, cursor);
});
Returns the angle in radians between
aandb.Eg if
ais the origin, andbis another point, in degrees one would get 0 to -180 whenbwas abovea. -180 would bebin line witha. Same for undera.Providing a third point
cgives the interior angle, wherebis the middle point.See also angleRadianCircle which returns coordinates on 0..Math.Pi*2 range. This avoids negative numbers.