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 double |
degree
The number of radians in a degree.
|
static int |
digits
The number of binary digits in the fraction of a double precision
number (equivalent to C++'s
numeric_limits<double>::digits). |
static double |
epsilon
Equivalent to C++'s
numeric_limits<double>::epsilon(). |
static double |
min
Equivalent to C++'s
numeric_limits<double>::min(). |
| Modifier and Type | Method and Description |
|---|---|
static double |
AngDiff(double x,
double y)
Difference of two angles reduced to [−180°, 180°]
|
static double |
AngNormalize(double x)
Normalize an angle (restricted input range).
|
static double |
AngRound(double x) |
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 double |
cbrt(double x)
The cube root function.
|
static double |
hypot(double x,
double y)
The hypotenuse function avoiding underflow and overflow.
|
static boolean |
isfinite(double x)
Test for finiteness.
|
static double |
LatFix(double x)
Normalize a latitude.
|
static double |
log1p(double x)
log(1 + x) accurate near x = 0.
|
static Pair |
norm(double sinx,
double cosx) |
static double |
polyval(int N,
double[] p,
int s,
double x)
Evaluate a polynomial.
|
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 final double epsilon
numeric_limits<double>::epsilon(). In Java
version 1.5 and later, Math.ulp(1.0) can be used.public static final double min
numeric_limits<double>::min(). In Java
version 1.6 and later, Double.MIN_NORMAL can be used.public static final double degree
public static double sq(double x)
x - the argument.public static double hypot(double x,
double y)
x - the first argument.y - the second argument.public static double log1p(double x)
This is taken from D. Goldberg, What every computer scientist should know about floating-point arithmetic (1991), Theorem 4. See also, N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd Edition (SIAM, 2002), Answer to Problem 1.5, p 528.
x - the argument.public static double atanh(double x)
x - the argument.public static double cbrt(double x)
x - the argument.public static Pair norm(double sinx, double cosx)
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)
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 double AngDiff(double x,
double y)
x - the first angle in degrees.y - the second angle in degrees.x and y must both lie in [−180°, 180°]. The result is equivalent to computing the difference exactly, reducing it to (−180°, 180°] and rounding the result. Note that this prescription allows −180° to be returned (e.g., if x is tiny and negative and y = 180°).
public static Pair sincosd(double x)
x - in degrees.public static double atan2d(double y,
double x)
y - x - public static boolean isfinite(double x)
x - the argument.Copyright © 2015. All Rights Reserved.