# Inverse trig functions

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

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.

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

``````float invsin = asin(num);
``````

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

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

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

The value of Pi isn't included with math.h. You should just do something like:

``````#define PI 3.14.....
``````

Then you can just use the "PI" definition where needed.

Jsut210: The value of Pi isn't included with math.h. You should just do something like:

``````#define PI 3.14.....
``````

Then you can just use the "PI" definition where needed.

WizenedEE:

Jsut210: The value of Pi isn't included with math.h. You should just do something like:

``````#define PI 3.14.....
``````

Then you can just use the "PI" definition where needed.

Even Better

math.h does define: - avr-libc: <math.h>: Mathematics -

#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 )

WizenedEE:

Jsut210: The value of Pi isn't included with math.h. You should just do something like:

``````#define PI 3.14.....
``````

Then you can just use the "PI" definition where needed.

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?

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.

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.