Why is Math.Cos returning the wrong value?

后端 未结 2 1228
失恋的感觉
失恋的感觉 2021-01-18 18:27

In my code:

Vector2 colCircle = new Vector2();

colCircle = new Vector2((R * Math.Sin(D)), -(R * Math.Cos(D)));

While:

R =          


        
相关标签:
2条回答
  • 2021-01-18 18:53

    Replace what you have with

    colCircle = new Vector2((R * Math.Sin(D*Math.PI/180.0)), -(R * Math.Cos(D*Math.PI/180.0))); 
    

    and you should be fine. Cos/Sin are expecting radians not degrees.

    0 讨论(0)
  • 2021-01-18 18:58

    The trigonometric functions expect radians, not degrees.

    0 讨论(0)
提交回复
热议问题