|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Arcsin?
How do you calculate arcsin? edit: In Java?
I've seen that their should be a Math.asin, but netbeans doesn't recognize it. |
|
#2
|
||||
|
||||
|
Re: Arcsin?
Just curious, what are you calculating that requires arcsine ?
|
|
#3
|
||||
|
||||
|
Re: Arcsin?
Looks like com.sun.squawk.util.MathUtils has what you're looking for:
http://www.wbrobotics.com/javadoc/co...MathUtils.html --Ryan |
|
#4
|
||||
|
||||
|
Re: Arcsin?
The FRC Java library does not contain an arcsine method. The math class in the FRC Java library is a very stripped down version of the actual Java.Math class.
|
|
#5
|
||||
|
||||
|
Re: Arcsin?
|
|
#6
|
||||
|
||||
|
Re: Arcsin?
Quote:
|
|
#7
|
||||
|
||||
|
Re: Arcsin?
Or you could roll your own. Accurate to less than 3 minutes of arc. Code:
#include <math.h>
double asin (double x) {
const double pi2=1.57079632679;
const double hroot2=0.707106781186;
double f(double x);
if (x<-hroot2) return -pi2+f(sqrt(1-x*x));
else if (x<0) return -f(-x);
else if (x<hroot2) return f(x);
else return pi2-f(sqrt(1-x*x));
}
double f(double x) {
return -0.000786215+x*(1.021878945+x*(-0.118183378+x*(0.344819444)));
}
void main (void) {
int i;
for (i=-100;i<=100;i++) printf("%f,%f\n",0.01*i,asin(0.01*i));
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|