public class GeoMath extends Object
Define mathematical functions and constants so that any version of Java can be used.
| Modifier and Type | Field and Description |
|---|---|
static int |
digits
The number of binary digits in the fraction of a double precision
number (equivalent to C++'s
numeric_limits<double>::digits). |
| Modifier and Type | Method and Description |
|---|---|
static Pair |
AngDiff(double x,
double y)
The exact difference of two angles reduced to (−180°, 180°].
|
static double |
AngNormalize(double x)
Normalize an angle.
|
static double |
AngRound(double x)
Coarsen a value close to zero.
|
static double |
atan2d(double y,
double x)
Evaluate the atan2 function with the result in degrees
|
static double |
atanh(double x)
The inverse hyperbolic tangent function.
|
static boolean |
isfinite(double x)
Test for finiteness.
|
static double |
LatFix(double x)
Normalize a latitude.
|
static Pair |
norm(double sinx,
double cosx)
Normalize a sine cosine pair.
|
static double |
polyval(int N,
double[] p,
int s,
double x)
Evaluate a polynomial.
|
static double |
remainder(double x,
double y)
The remainder function.
|
static Pair |
sincosd(double x)
Evaluate the sine and cosine function with the argument in degrees
|
static double |
sq(double x)
Square a number.
|
static Pair |
sum(double u,
double v)
The error-free sum of two numbers.
|
public static final int digits
numeric_limits<double>::digits).public static double sq(double x)
x - the argument.public static double atanh(double x)
x - the argument.public static Pair norm(double sinx, double cosx)
sinx - the sine.cosx - the cosine.public static Pair sum(double u, double v)
u - the first number in the sum.v - the second number in the sum.See D. E. Knuth, TAOCP, Vol 2, 4.2.2, Theorem B.
public static double polyval(int N,
double[] p,
int s,
double x)
N - the order of the polynomial.p - the coefficient array (of size N + s + 1 or more).s - starting index for the array.x - the variable.public static double AngRound(double x)
x - the argumentThis makes the smallest gap in x = 1/16 − nextafter(1/16, 0) = 1/257 for reals = 0.7 pm on the earth if x is an angle in degrees. (This is about 1000 times more resolution than we get with angles around 90 degrees.) We use this to avoid having to deal with near singular cases when x is non-zero but tiny (e.g., 10−200). This converts −0 to +0; however tiny negative numbers get converted to −0.
public static double remainder(double x,
double y)
x - the numerator of the divisiony - the denominator of the divisionThe range of x is unrestricted; y must be positive.
public static double AngNormalize(double x)
x - the angle in degrees.The range of x is unrestricted.
public static double LatFix(double x)
x - the angle in degrees.public static Pair AngDiff(double x, double y)
x - the first angle in degrees.y - the second angle in degrees.The computes z = y − x exactly, reduced to (−180°, 180°]; and then sets z = d + e where d is the nearest representable number to z and e is the truncation error. If d = −180, then e > 0; If d = 180, then e ≤ 0.
public static Pair sincosd(double x)
x - in degrees.public static double atan2d(double y,
double x)
y - the sine of the anglex - the cosine of the anglepublic static boolean isfinite(double x)
x - the argument.Copyright © 2019. All Rights Reserved.