[Math] Measuring angle of diagonal from vertical

trigonometry

I need to calculate the degrees from vertical of a diagonal line, from 0 to -180, clockwise. I have used arctan to find out the degrees, but that gives me angles out of 90, with the sign depending on the quadrant. Conversion to what I need would be messy.
Is there a function I can use to get me straight there, if that makes sense?
Thanks

EDIT: The line is drawn between the centre of the screen and the position of the mouse. The angle I would like to calculate is the slope of the diagonal between these points, in a 0 to -180 degree system, clockwise. Like longitude is measured.

enter image description here
I would expect the red line to have an angle of -135.

Best Answer

Perhaps the atan2 function would be of use to you. It returns a value from -π to +π in radians. Convert the value to degrees, and you should have a proper answer.

Related Question