Go Down

Topic: math and cosinus (Read 382 times) previous topic - next topic

GekoCH

Hy

Hmm I like to calculate the cos-1() but when I use acos the result is wrong.
So: cos-1(500/1000) => 60° the Arduino does calculate 90° why?

This is the code:
Code: [Select]

float alpha = acos(500/1000);
int grad = alpha*57.2957795131; //is the same as (180/pi)
Serial.println(grad);


What am I doing wrong?

THx
Andy

AWOL

Code: [Select]
acos(500/1000);
is the same as
Code: [Select]
acos(0);

Try:
Code: [Select]
acos(500.0/1000.0);
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

GekoCH

ahhhhh sorry for that but how could I miss that!!!

Thx a lot you saved me a lot of time :)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy