How to convert x,y coordinates to an angle?

前端 未结 6 831
暗喜
暗喜 2020-12-13 06:49

Microsoft provide an excellent SVG gradient maker so IE9 can also have \"CSS3\" gradients (click Custom).

I currently utilise their logic for my Fireworks and Dreamw

6条回答
  •  执笔经年
    2020-12-13 07:01

    Instead of using Math.tan function You should use Math.atan2:

    Here is an example of use:

    deltaX = x2 - x1;
    deltaY = y2 - y1;
    deg = Math.atan2(deltaY, deltaX)*180.0/Math.PI;
    

    and this will return a degree from <-180;180>.

提交回复
热议问题