View Full Version : Arcsin?
tutkows1
03-03-2011, 17:33
How do you calculate arcsin? edit: In Java?
I've seen that their should be a Math.asin, but netbeans doesn't recognize it.
How do you calculate arcsin?
Just curious, what are you calculating that requires arcsine ?
RyanCahoon
03-03-2011, 21:52
Looks like com.sun.squawk.util.MathUtils has what you're looking for:
http://www.wbrobotics.com/javadoc/com/sun/squawk/util/MathUtils.html
--Ryan
Anupam Goli
03-03-2011, 21:53
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.
EHaskins
03-03-2011, 21:56
Asin can be found as MathUtils.asin.
http://www.sunspotworld.com/docs/Orange/javadoc/com/sun/squawk/util/MathUtils.html
Anupam Goli
03-03-2011, 22:12
Asin can be found as MathUtils.asin.
http://www.sunspotworld.com/docs/Orange/javadoc/com/sun/squawk/util/MathUtils.html
Yea, he's right. Ignore what i said earlier, it should be in the MathUtils class. Click the logo in netbeans and find the class in the api documentation. Remember, all of those methods are static so you have to refer to them as MathUtils.asin(double a);
Or you could roll your own. Accurate to less than 3 minutes of arc.
#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));
}
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.