Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Arcsin? (http://www.chiefdelphi.com/forums/showthread.php?t=93173)

tutkows1 03-03-2011 17:33

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.

Ether 03-03-2011 18:31

Re: Arcsin?
 
Quote:

Originally Posted by tutkows1 (Post 1034239)
How do you calculate arcsin?

Just curious, what are you calculating that requires arcsine ?




RyanCahoon 03-03-2011 21:52

Re: Arcsin?
 
Looks like com.sun.squawk.util.MathUtils has what you're looking for:

http://www.wbrobotics.com/javadoc/co...MathUtils.html

--Ryan

Anupam Goli 03-03-2011 21:53

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.

EHaskins 03-03-2011 21:56

Re: Arcsin?
 
Asin can be found as MathUtils.asin.

http://www.sunspotworld.com/docs/Ora...MathUtils.html

Anupam Goli 03-03-2011 22:12

Re: Arcsin?
 
Quote:

Originally Posted by EHaskins (Post 1034338)
Asin can be found as MathUtils.asin.

http://www.sunspotworld.com/docs/Ora...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);

Ether 05-03-2011 16:04

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));
}




All times are GMT -5. The time now is 11:35.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi