Go Down

Topic: Inverse trig functions (Read 3742 times) previous topic - next topic

Jetfire

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.

Jsut210

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

Code: [Select]

float invsin = asin(num);

codlink

#2
Apr 05, 2013, 12:37 am Last Edit: Apr 05, 2013, 12:44 am by codlink Reason: 1
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
//LiNK

robtillaart

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

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

Jetfire

#4
Apr 05, 2013, 09:54 pm Last Edit: Apr 05, 2013, 10:21 pm by Jetfire Reason: 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

Jsut210

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

#define PI 3.14.....

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

WizenedEE


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

#define PI 3.14.....

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


Arduino.h already defines PI

Jsut210



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

#define PI 3.14.....

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


Arduino.h already defines PI

Even Better

robtillaart

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 )
Rob Tillaart

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

Jetfire



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

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

PaulS

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.

Jsut210

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.

Go Up