finding angles 0-360

前端 未结 10 1826
清酒与你
清酒与你 2020-12-25 15:16

Need help with a math issue: i need to get the true angle from 0 degrees using x and y cordinates im using this at the moment:

Math.atan((x2-x1)/(y1-y2))/(Ma         


        
10条回答
  •  旧巷少年郎
    2020-12-25 16:02

    so with a single decesion (i hope this ugly basiclike notation explains it):

    IF x = 0 THEN

    360degree = 270 - (SIGN(x) + 1) * 90

    ELSE

    360degree = MOD(180 + (SIGN(y) + 1) * 90 + ATAN(x/y) , 360)

    ENDIF

    to draw a full circle from north 0degree to 360degree clockwise:

    x=SIN(0to360) y=COS(0to360)

    cheers, Lev

提交回复
热议问题