Math
Properties
The number of degrees in a radian.
4 * 1024 * 1024 * 1024
The gravitational parameter of the Earth in meters cubed per second squared as defined by the WGS84 model: 3.986004418e14
The mean radius of the moon, according to the "Report of the IAU/IAG Working Group on Cartographic Coordinates and Rotational Elements of the Planets and satellites: 2000", Celestial Mechanics 82: 83-110, 2002.
1/pi
1/2pi
pi/4
pi/6
pi/3
pi/2
The number of radians in an arc second.
The number of radians in a degree.
64 * 1024
Radius of the sun in meters: 6.955e8
3pi/2
Functions
Computes Math.acos(value)
, but first clamps value
to the range -1.0, 1.0 so that the function will never return NaN.
Computes Math.asin(value)
, but first clamps value
to the range -1.0, 1.0 so that the function will never return NaN.
Finds the chord length between two points given the circle's radius and the angle between the points.
Convenience function that clamps a latitude value, in radians, to the range [-Math.PI/2
, Math.PI/2
). Useful for sanitizing data before use in objects requiring correct range.
Converts a longitude value, in radians, to the range [-Math.PI
, Math.PI
).
Determines if two values are equal using an absolute or relative tolerance test. This is useful to avoid problems due to roundoff error when comparing floating-point values directly. The values are first compared using an absolute tolerance test. If that fails, a relative tolerance test is performed. Use this test if you are unsure of the magnitudes of left and right.
Computes a fast approximation of Atan for input in the range -1, 1.
Computes a fast approximation of Atan2(x, y) for arbitrary input scalars.
Determines if the left value is greater the right value. If the two values are within absoluteEpsilon
of each other, they are considered equal and this function returns false.
Determines if the left value is greater than or equal to the right value. If the two values are within absoluteEpsilon
of each other, they are considered equal and this function returns true.
Increments a number with a wrapping to a minimum value if the number exceeds the maximum value.
Determines if a non-negative integer is a power of two. The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript.
Determines if the left value is less than or equal to the right value. If the two values are within absoluteEpsilon
of each other, they are considered equal and this function returns true.
Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.
Computes the next power-of-two integer greater than or equal to the provided non-negative integer. The maximum allowed input is 2^31 due to 32-bit bitwise operator limitation in Javascript.
Generates a random floating point number in the range of [0.0, 1.0) using a Mersenne twister.
Computes the previous power-of-two integer less than or equal to the provided non-negative integer. The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript.
Generates a random number between two numbers.
Sets the seed used by the random number generator in Math.nextRandomNumber.
Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. This is similar to Math.sign except that returns 1.0 instead of 0.0 when the input value is 0.0.
Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.