Why is Math.Cos returning the wrong value?

后端 未结 2 1242
失恋的感觉
失恋的感觉 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条回答
  •  Happy的楠姐
    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.

提交回复
热议问题