Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why isthe Cos function in C# givingme a wrong answers?

I have a method, in wich i am using the Cos() Funcion from the namepace "Mathf".
Sadly, when i give , for exaple the in put of 45 it returns 0,52532, wich is wrong. Using a calculator i get the correct answer of 6.283185 Radiants.

float angle = 45;
Debug.Log(Mathf.Cos(angle));

Prints out:

0,525322

Can anyone help me out here? I am very confused right now

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to convert to radians.

float angle = 45;
Debug.Log(Mathf.Cos(angle * Math.PI / 180.0f));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading