Js calculates the rotation angle, but I can't understand it. Can you help me?

this is what I found on the Internet, centerx mouse click to get clientx,endx mouse movement to get e.clientx,
360 Math.atan2 (diff_y, diff_x) z this 360 is using 360 degrees, I really don"t understand

.
var diff_x = endx - centerx, // 
    diff_y = endy - centery // 
var c = 360 * Math.atan2(diff_y, diff_x) / (2 * Math.PI)
360+c
c = c <= -90 ? (360 + c) : c
return c + 90
Nov.04,2021

take a look at this link description


question 1: how does it work?
Mathematical principles
timg?image&quality=80&size=b9999_10000&sec=1541860748242&di=22f733b0bbee23c640ae21c92143363e&imgtype=0&src=http%3A%2F%2Fwww.syhxlx.cn%2Fupload%2Fimg%2FrtHYh4BMxtGw3hfPpivZI5zvd4AI9%2FFesXo0VX4CEVMaF8rtOjopZlGNJZrI6yf7KPaSFQeTnMR7UlpxyVViVdx44WSapqo.jpg

question 2: why do you end up using 360C
to turn into a positive angle

Menu