I apologize, I should know this. I have 2 points on an SVG 2d coordinate system. I need to get the degrees (0-360) and all I can return right now is 0-180 back to 0 with no negative or positive sign on the 0-180... I can find close questions but none that result in 0-360.
Here is the code in javascript:
// center point, say 200,200
var rx = that.get("rotateOriginX"); // ember code but substitute 200,200 if you want
var ry = that.get("rotateOriginY");
// I create third point (directly up on coordinate system)
// 200, 190 - line straight up and down to angle vertex above
var p1x = rx;
var p1y = ry - 10; // this is negative 10 to go up because svg y axis starts in upper left
// mouse position variable, this can be 360 degrees around vertex
var p2x = d3.mouse(this.parentNode.parentNode)[0];
var p2y = d3.mouse(this.parentNode.parentNode)[1];
// I have three points now
var p0c = Math.sqrt(Math.pow(rx-p1x, 2) + Math.pow(ry-p1y, 2));
var p1c = Math.sqrt(Math.pow(rx-p2x, 2) + Math.pow(ry-p2y, 2));
var p0p1 = Math.sqrt(Math.pow(p2x-p1x, 2) + Math.pow(p2y-p1y, 2));
// this always returns 0-180-0 but is not signed (+/-)
// ALL I WANT IS 0-360 so I can rotate a shape to user's preference as determined by mouse
var degrees = (180 * (Math.acos((p1c*p1c+p0c*p0c-p0p1*p0p1)/(2*p1c*p0c))) / Math.PI);