How to calculate rotation in 2D in Javascript

前端 未结 5 1818
旧巷少年郎
旧巷少年郎 2020-12-07 17:07

I am not so familiar trigonometry, but I have only two points to rotate in 2D:

                    *nx, ny
               .     -
          .           -
            


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 17:12

    According to Polar coordinate system artycle on Wikipedia:

    x = r * cos(deg)
    y = r * sin(deg)
    
    • r (radius) is equal to distance between Rotation Centre and Rotated Point
    • deg (degrees) is angle measured in degrees

提交回复
热议问题