Some useful mathematical constants and functions (mainly for internal use).
Members
(static) atanh
Inverse hyperbolic tangent.
(static) cbrt
Cube root function.
(static, constant) degree :number
The factor to convert degrees to radians.
Type:
- number
(static, constant) digits :number
The number of digits of precision in floating-point numbers.
Type:
- number
(static, constant) epsilon :number
The machine epsilon.
Type:
- number
(static) log1p
The log1p function.
Methods
(static) AngDiff(x, y) → {object}
The exact difference of two angles reduced to [−180°, 180°]
Parameters:
Name | Type | Description |
---|---|---|
x |
number | the first angle in degrees. |
y |
number | the second angle in degrees. |
Returns:
diff the exact difference, diff.d + diff.e = y − x mod 360°.
This 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 z = ±0° or ±180°, then the sign of d is given by the sign of y − x. The maximum absolute value of e is 2−26 (for doubles).
- Type
- object
(static) AngNormalize(x) → {number}
Normalize an angle.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | the angle in degrees. |
Returns:
the angle reduced to the range [−180°, 180°].
The range of x is unrestricted. If the result is ±0° or ±180° then the sign is the sign of \e x.
- Type
- number
(static) AngRound(x) → {number}
Coarsen a value close to zero.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
Returns:
the coarsened value.
- Type
- number
(static) LatFix(x) → {number}
Normalize a latitude.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | the angle in degrees. |
Returns:
x if it is in the range [−90°, 90°], otherwise return NaN.
- Type
- number
(static) atan2d(y, x)
Evaluate the atan2 function with the result in degrees
Parameters:
Name | Type | Description |
---|---|---|
y |
number | |
x |
number |
Returns:
atan2(y, x) in degrees, in the range [−180° 180°].
(static) copysign(x, y) → {number}
Copy the sign.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | gives the magitude of the result. |
y |
number | gives the sign of the result. |
Returns:
value with the magnitude of x and with the sign of y.
- Type
- number
(static) hypot(x, y) → {number}
The hypotenuse function.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | the first side. |
y |
number | the second side. |
Returns:
the hypotenuse.
- Type
- number
(static) polyval(N, p, x) → {number}
Evaluate a polynomial.
Parameters:
Name | Type | Description |
---|---|---|
N |
integer | the order of the polynomial. |
p |
array | the coefficient array (of size N + 1) (leading order coefficient first) |
x |
number | the variable. |
Returns:
the value of the polynomial.
- Type
- number
(static) remainder(x, y) → {number}
The remainder function.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | the numerator of the division |
y |
number | the denominator of the division |
Returns:
the remainder in the range [−y/2, y/2].
The range of x is unrestricted; y must be positive.
- Type
- number
(static) sincosd(x) → {object}
Evaluate the sine and cosine function with the argument in degrees
Parameters:
Name | Type | Description |
---|---|---|
x |
number | in degrees. |
Returns:
r with r.s = sin(x) and r.c = cos(x).
- Type
- object
(static) sincosde(x, t) → {object}
Evaluate the sine and cosine with reduced argument plus correction
Parameters:
Name | Type | Description |
---|---|---|
x |
number | reduced angle in degrees. |
t |
number | correction in degrees. |
Returns:
r with r.s = sin(x + t) and r.c = cos(x + t).
- Type
- object
(static) sq(x) → {number}
Square a number.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | the number. |
Returns:
the square.
- Type
- number
(static) sum(u, v) → {object}
An error-free sum.
Parameters:
Name | Type | Description |
---|---|---|
u |
number | |
v |
number |
Returns:
sum with sum.s = round(u + v) and sum.t is u + v − round(u + v)
- Type
- object