Skip to content

KBE3D / KBCore / Cesium / Math

Math

Math functions.

函数

函数描述
signReturns the sign of the value; 1 if the value is positive, -1 if the value is negative, or 0 if the value is 0.
signNotZeroReturns 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.
toSNormConverts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMaximum]
fromSNormConverts a SNORM value in the range [0, rangeMaximum] to a scalar in the range [-1.0, 1.0].
normalizeConverts a scalar value in the range [rangeMinimum, rangeMaximum] to a scalar in the range [0.0, 1.0]
sinhReturns the hyperbolic sine of a number. The hyperbolic sine of value is defined to be (ex - e-x)/2.0 where e is Euler's number, approximately 2.71828183.
coshReturns the hyperbolic cosine of a number. The hyperbolic cosine of value is defined to be (ex + e-x)/2.0 where e is Euler's number, approximately 2.71828183.
lerpComputes the linear interpolation of two values.
toRadiansConverts degrees to radians.
toDegreesConverts radians to degrees.
convertLongitudeRangeConverts a longitude value, in radians, to the range [-Math.PI, Math.PI).
clampToLatitudeRangeConvenience 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.
negativePiToPiProduces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.
zeroToTwoPiProduces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.
modThe modulo operation that also works for negative dividends.
equalsEpsilonDetermines 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.
lessThanDetermines if the left value is less than the right value. If the two values are within absoluteEpsilon of each other, they are considered equal and this function returns false.
lessThanOrEqualsDetermines 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.
greaterThanDetermines 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.
greaterThanOrEqualsDetermines 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.
factorialComputes the factorial of the provided number.
incrementWrapIncrements a number with a wrapping to a minimum value if the number exceeds the maximum value.
isPowerOfTwoDetermines 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.
nextPowerOfTwoComputes 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.
previousPowerOfTwoComputes 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.
clampConstraint a value to lie between two values.
setRandomNumberSeedSets the seed used by the random number generator in Math#nextRandomNumber.
nextRandomNumberGenerates a random floating point number in the range of [0.0, 1.0) using a Mersenne twister.
randomBetweenGenerates a random number between two numbers.
acosClampedComputes Math.acos(value), but first clamps value to the range [-1.0, 1.0] so that the function will never return NaN.
asinClampedComputes Math.asin(value), but first clamps value to the range [-1.0, 1.0] so that the function will never return NaN.
chordLengthFinds the chord length between two points given the circle's radius and the angle between the points.
logBaseFinds the logarithm of a number to a base.
cbrtFinds the cube root of a number. Returns NaN if number is not provided.
log2Finds the base 2 logarithm of a number.
fastApproximateAtanComputes a fast approximation of Atan for input in the range [-1, 1].
fastApproximateAtan2Computes a fast approximation of Atan2(x, y) for arbitrary input scalars.

变量

变量描述
EPSILON10.1
EPSILON20.01
EPSILON30.001
EPSILON40.0001
EPSILON50.00001
EPSILON60.000001
EPSILON70.0000001
EPSILON80.00000001
EPSILON90.000000001
EPSILON100.0000000001
EPSILON110.00000000001
EPSILON120.000000000001
EPSILON130.0000000000001
EPSILON140.00000000000001
EPSILON150.000000000000001
EPSILON160.0000000000000001
EPSILON170.00000000000000001
EPSILON180.000000000000000001
EPSILON190.0000000000000000001
EPSILON200.00000000000000000001
EPSILON210.000000000000000000001
GRAVITATIONALPARAMETERThe gravitational parameter of the Earth in meters cubed per second squared as defined by the WGS84 model: 3.986004418e14
SOLAR_RADIUSRadius of the sun in meters: 6.955e8
LUNAR_RADIUSThe 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.
SIXTY_FOUR_KILOBYTES64 * 1024
FOUR_GIGABYTES4 * 1024 * 1024 * 1024
PIpi
ONE_OVER_PI1/pi
PI_OVER_TWOpi/2
PI_OVER_THREEpi/3
PI_OVER_FOURpi/4
PI_OVER_SIXpi/6
THREE_PI_OVER_TWO3pi/2
TWO_PI2pi
ONE_OVER_TWO_PI1/2pi
RADIANS_PER_DEGREEThe number of radians in a degree.
DEGREES_PER_RADIANThe number of degrees in a radian.
RADIANS_PER_ARCSECONDThe number of radians in an arc second.

KBE3D @3.0.0 Copyright © 2024-present KBE3D