Pages: [1]   Go Down
Author Topic: Inverse trig functions  (Read 3359 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

They locked this topic away in the arcives, so I'll just do this:


http://arduino.cc/forum/index.php?PHPSESSID=99fdf9fb9ed775fd5c50e3e70f03aec8&topic=41402.0


I need the <math.h> library and I can't find the .h and .ccp files.
Or if you could just tell me how to get the arc functions that would work too.

Thanks.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This may help http://arduino.cc/forum/index.php/topic,44229.0.html  
What happens if you just try something like:

Code:
float invsin = asin(num);
Logged

USA, FL
Offline Offline
God Member
*****
Karma: 14
Posts: 689
A life? Where can I download one of those?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

He's trying to tell you that the math library is already including in the IDE.  And actually, you don't have to use a header to include it either. [ref]http://arduino.cc/en/Math/H

Here's another library if you need more complexity.

http://playground.arduino.cc/Main/ComplexMath
« Last Edit: April 04, 2013, 05:44:47 pm by codlink » Logged

//LiNK

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14027
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

note that the asin() return radians
- http://www.nongnu.org/avr-libc/user-manual/group__avr__math.html -

The returned value is in the range [-pi/2, pi/2] radians. A domain error occurs for arguments not in the range [-1, +1].
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok cool

Rewrote my arcsin() as asin and that compiled fine.


Including the conversion formula for radians to degrees didn't work so well.

The value pi is apparently not included in the package.

Should I just use "3.14159265358979323846" or is there some other way?


Thanks
« Last Edit: April 05, 2013, 03:21:03 pm by Jetfire » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The value of Pi isn't included with math.h.  You should just do something like:
Code:
#define PI 3.14.....
Then you can just use the "PI" definition where needed.
Logged

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The value of Pi isn't included with math.h.  You should just do something like:
Code:
#define PI 3.14.....
Then you can just use the "PI" definition where needed.

Arduino.h already defines PI
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The value of Pi isn't included with math.h.  You should just do something like:
Code:
#define PI 3.14.....
Then you can just use the "PI" definition where needed.

Arduino.h already defines PI
Even Better
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14027
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

math.h does define: - http://www.nongnu.org/avr-libc/user-manual/group__avr__math.html -

#define    M_PI   3.14159265358979323846   /* pi */
#define    M_PI_2   1.57079632679489661923   /* pi/2 */
#define    M_PI_4   0.78539816339744830962   /* pi/4 */
#define    M_1_PI   0.31830988618379067154   /* 1/pi */
#define    M_2_PI   0.63661977236758134308   /* 2/pi */
#define    M_2_SQRTPI   1.12837916709551257390   /* 2/sqrt(pi) */


unfortunately math.h does not define 180/PI and PI/180  for radians <> degrees conversion
(windows calc)
#define     M_180_PI  57,295779513082320876798154814105   /*180/pi */
#define     M_PI_180  0,01745329251994329576923690768489    /* pi/180 */

// the arduino does only support about 7 digits of float precision so the above numbers are overkill  (unless the arbitrary precision lib is used )
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The value of Pi isn't included with math.h.  You should just do something like:
Code:
#define PI 3.14.....
Then you can just use the "PI" definition where needed.

Arduino.h already defines PI

OK

I changed pi to PI and it compiled OK

I'm waiting for hardware to test it out.

Anyone know where I can get 20-25 servos for under $100?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 653
Posts: 50883
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Anyone know where I can get 20-25 servos for under $100?
20 minus 25 is -5. You could send me 5 servos and $100, and you'd have -5 servos for $100.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

These are about the cheapest servos you can get:

http://www.ebay.com/itm/Micro-9g-Mini-RC-Servo-for-Trex-450-Futaba-Hitec-HS-55-Align-GWS-JR-Walkera-Heli-/140922521530?pt=LH_DefaultDomain_0&hash=item20cfa307ba

Yep, straight from china.  Keep in mind that you get what you pay for.
Logged

Pages: [1]   Go Up
Jump to: