Pages: [1]   Go Down
Author Topic: math and cosinus  (Read 297 times)
0 Members and 1 Guest are viewing this topic.
Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 276
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26487
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Try:
Code:
acos(500.0/1000.0);
Logged

"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.

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 276
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Thx a lot you saved me a lot of time smiley
Logged

Pages: [1]   Go Up
Jump to: