J2ME里面的一些未实现的三角函数

今天搞J2ME里面计算经纬度,没想到J2ME这么多限制,连几个很简单的三角函数也不给提供完全,还要直接写.没办法,自己动手好了.留个代码,方便以后参考学习吧.
package com.ken.math;

/***/ /**
*通过计算公式实现反正切、反正弦、反余弦<br>
*Tan(X)=Sin(X)/Cos(x)<br>
*ArcSin(X)=ArcTan(X/Sqrt(1-Sqr(X)))<br>
*ArcCos(X)=ArcTan(Sqrt(1-Sqr(X))/X)<br>
*
*
@author<ahref="mailto:[email protected]">Ken_xu</a>
*
@version1.0Copyright2008-5-4下午04:09:04
*/

public class SuperMath ... {
/***//**
*反正切<br>
*radian为正切值,这个函数的值域为-π/2~π/2
*
*
@paramradian
*弧度为单位的角度
*
@return该角度所对应的反正切
*
@authorKen_xu
*/

publicstaticdoubleactTan(doubleradian)...{
System.out.println(radian);
doubleretval=0d;
if(Math.abs(radian)<=1.0d)...{
retval
=radian/(1.0D+0.28d*sqr(radian));
}
else...{
retval
=-radian/(sqr(radian)+0.28d);
if(radian<-1.0d)...{
retval
=retval-Math.PI/2;
}
else...{
retval
=retval+Math.PI/2;
}

}

returnretval;
}


/***//**
*反正切<br>
*正切值为y/x,因此该函数求的是y/x所对应的角,这个函数的值域为-π~π
*
*
@paramy
*
@paramx
*
@return该角度所对应的反正切
*
@authorKen_xu
*/

publicstaticdoubleactTan(doubley,doublex)...{
if(y==0.0d&&x==0.0d)
return0.0d;
if(x>0.0d)
returnactTan(y/x);
if(x<0.0F)
if(y<0.0d)
return(-(Math.PI-actTan(y/x)));
else
return(Math.PI-actTan(-y/x));
returny>=0.0F?Math.PI/2:Math.PI/2;
}


/***//**
*反正弦
*
*
@paramradian
*弧度为单位的角度
*
@return该角度所对应的反正弦
*
@authorKen_xu
*/

publicstaticdoubleactSin(doubleradian)...{
//ArcSin(X)=ArcTan(X/Sqrt(1-Sqr(X)))
doubleretval=actTan(radian/Math.sqrt(1-sqr(radian)));
returnretval;
}


/***//**
*反余弦
*
*
@paramradian
*弧度为单位的角度
*
@return该角度所对应的反余弦
*
@authorKen_xu
*/

publicstaticdoubleactCos(doubleradian)...{
//ArcCos(X)=ArcTan(Sqrt(1-Sqr(X))/X)
doubleretval=actTan(Math.sqrt(1-sqr(radian))/radian);
returnretval;
}


/***//**
*平方函数
*
*
@paramx
*
@return平方值(x*x)
*
@authorKen_xu
*/

publicstaticdoublesqr(doublex)...{
returnx*x;
}

}


你可能感兴趣的:(Gmail)