Go Down

Topic: math and cosinus (Read 332 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