I did not expect so many limitations on the calculation of latitude and longitude in the J2EE today. Even a few simple trigonometric functions are not completely provided, and I need to write them directly. no way. Do it yourself. leave a code for reference later. package COM. ken. math;
/***//**
* Returns arc tangent, arcsin, and arccosine using the formula. <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 <a href = "mailto: xzknet@gmail.com"> ken_xu </a>
* @ Version 1.0 copyright 04:09:04
*/
Public class supermath ...{
/***//**
* Arc tangent <br>
* Radian is the tangent. The value range of this function is-π/2 ~ π/2
*
* @ Param radian
* Degrees in radians
* @ Return returns the arc tangent corresponding to the angle
* @ Author ken_xu
*/
Public static double acttan (double radian )...{
System. Out. println (radian );
Double retval = 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;
}
}
Return retval;
}
/***//**
* Arc tangent <br>
* The tangent value is Y/X. Therefore, this function calculates the angle corresponding to Y/X. The value of this function is-π ~ π
*
* @ Param y
* @ Param x
* @ Return returns the arc tangent corresponding to the angle
* @ Author ken_xu
*/
Public static double acttan (Double Y, double X )...{
If (y = 0.0d & X = 0.0d)
Return 0.0d;
If (x> 0.0d)
Return acttan (y/X );
If (x <0.0f)
If (Y <0.0d)
Return (-(math. Pi-acttan (y/X )));
Else
Return (math. Pi-acttan (-y/X ));
Return y> = 0.0f? Math. PI/2: Math. PI/2;
}
/***//**
* ARC sine
*
* @ Param radian
* Degrees in radians
* @ Return the arcsin corresponding to the angle
* @ Author ken_xu
*/
Public static double actsin (double radian )...{
// Arcsin (x) = arctan (x/SQRT (1-sqr (X )))
Double retval = acttan (radian/Math. SQRT (1-sqr (radian )));
Return retval;
}
/***//**
* Arccosine
*
* @ Param radian
* Degrees in radians
* @ Return returns the arc cosine of the angle.
* @ Author ken_xu
*/
Public static double actcos (double radian )...{
// Arccos (x) = arctan (SQRT (1-sqr (x)/X)
Double retval = acttan (math. SQRT (1-sqr (radian)/radian );
Return retval;
}
/***//**
* Square Functions
*
* @ Param x
* @ Return square value (x * X)
* @ Author ken_xu
*/
Public static double sqr (Double X )...{
Return x * X;
}
}