Module: WWMath

Provides math constants and functions.
Source:

Methods

(static) boundingRectForUnitQuad(transformMatrix) → {Rectangle}

Computes the bounding rectangle for a unit quadrilateral after applying a transformation matrix to that quadrilateral.
Parameters:
Name Type Description
transformMatrix Matrix The matrix to apply to the unit quadrilateral.
Source:
Returns:
The computed bounding rectangle.
Type
Rectangle

(static) cbrt(x) → {Number}

Returns the cube root of a specified value.
Parameters:
Name Type Description
x Number The value whose cube root is computed.
Source:
Returns:
The cube root of the specified number.
Type
Number

(static) clamp(value, minimum, maximum) → {Number}

Returns a number within the range of a specified minimum and maximum.
Parameters:
Name Type Description
value Number The value to clamp.
minimum Number The minimum value to return.
maximum Number The maximum value to return.
Source:
Returns:
The minimum value if the specified value is less than the minimum, the maximum value if the specified value is greater than the maximum, otherwise the value specified is returned.
Type
Number

(static) computeEllipsoidalGlobeIntersection(line, equatorialRadius, polarRadius, result) → {boolean}

Computes the Cartesian intersection point of a specified line with an ellipsoid.
Parameters:
Name Type Description
line Line The line for which to compute the intersection.
equatorialRadius Number The ellipsoid's major radius.
polarRadius Number The ellipsoid's minor radius.
result Vec3 A pre-allocated Vec3 instance in which to return the computed point.
Deprecated:
  • utilize the Globe.intersectsLine method attached implementation
Source:
Throws:
If the specified line or result is null or undefined.
Type
ArgumentError
Returns:
true if the line intersects the ellipsoid, otherwise false
Type
boolean

(static) computeTriangleIntersection(line, vertex0, vertex1, vertex2, result) → {boolean}

Computes the Cartesian intersection point of a specified line with a triangle.
Parameters:
Name Type Description
line Line The line for which to compute the intersection.
vertex0 Vec3 The triangle's first vertex.
vertex1 Vec3 The triangle's second vertex.
vertex2 Vec3 The triangle's third vertex.
result Vec3 A pre-allocated Vec3 instance in which to return the computed point.
Source:
Throws:
If the specified line, vertex or result is null or undefined.
Type
ArgumentError
Returns:
true if the line intersects the triangle, otherwise false
Type
boolean

(static) computeTriStripIntersections(line, points, indices, results)

Computes the Cartesian intersection points of a specified line with a triangle strip. The triangle strip is specified by a list of vertex points and a list of indices indicating the triangle strip tessellation of those vertices. The triangle strip indices are interpreted in the same manner as WebGL, where each index indicates a vertex position rather than an actual index into the points array (e.g. a triangle strip index of 1 indicates the XYZ tuple starting at array index 3). This is equivalent to calling computeTriangleIntersection for each individual triangle in the triangle strip, but is potentially much more efficient.
Parameters:
Name Type Description
line Line The line for which to compute the intersection.
points Array The list of vertex points, organized as a list of tightly-packed XYZ tuples.
indices Array The list of triangle strip indices, organized as a list of vertex positions.
results Array A pre-allocated array instance in which to return the intersection points as Vec3 instances.
Source:
Throws:
If the specified line, points, indices or results is null or undefined.
Type
ArgumentError

(static) fabs(a) → {Number}

Computes the absolute value of a specified value.
Parameters:
Name Type Description
a Number The value whose absolute value to compute.
Source:
Returns:
The absolute value of the specified number.
Type
Number

(static) fmod(number, modulus) → {Number}

Computes the floating-point modulus of a specified number.
Parameters:
Name Type Description
number Number The number whose modulus to compute.
modulus Number The modulus.
Source:
Returns:
The remainder after dividing the number by the modulus: number % modulus.
Type
Number

(static) fract(number) → {Number}

Returns the fractional part of a specified number
Parameters:
Name Type Description
number Number The number whose fractional part to compute.
Source:
Returns:
The fractional part of the specified number: number - floor(number).
Type
Number

(static) gudermannianInverse(latitude) → {Number}

Calculates the Gudermannian inverse used to unproject Mercator projections.
Parameters:
Name Type Description
latitude Number The latitude in degrees.
Source:
Returns:
The Gudermannian inverse for the specified latitude.
Type
Number

(static) horizonDistanceForGlobeRadius(radius, altitude) → {Number}

Computes the distance to a globe's horizon from a viewer at a given altitude. Only the globe's ellipsoid is considered; terrain height is not incorporated. This returns zero if the radius is zero or if the altitude is less than or equal to zero.
Parameters:
Name Type Description
radius Number The globe's radius, in meters.
altitude Number The viewer's altitude above the globe, in meters.
Source:
Throws:
If the specified globe radius is negative.
Type
ArgumentError
Returns:
The distance to the horizon, in model coordinates.
Type
Number

(static) interpolate(amount, value1, value2) → {Number}

Computes a number between two numbers.
Parameters:
Name Type Description
amount Number The relative distance between the numbers at which to compute the new number. This should normally be a number between 0 and 1 but whatever number is specified is applied.
value1 Number The first number.
value2 Number The second number.
Source:
Returns:
the computed value.
Type
Number

(static) isPowerOfTwo(value) → {boolean}

Indicates whether a specified value is a power of two.
Parameters:
Name Type Description
value Number The value to test.
Source:
Returns:
true if the specified value is a power of two, otherwise false.
Type
boolean

(static) localCoordinateAxesAtPoint(origin, globe, xAxisResult, yAxisResult, zAxisResult)

Computes the axes of a local coordinate system on the specified globe, placing the resultant axes in the specified axis arguments. Upon return the specified axis arguments contain three orthogonal axes identifying the X, Y, and Z axes. Each axis has unit length. The local coordinate system is defined such that the Z axis maps to the globe's surface normal at the point, the Y axis maps to the north pointing tangent, and the X axis maps to the east pointing tangent.
Parameters:
Name Type Description
origin Vec3 The local coordinate system origin, in model coordinates.
globe Globe The globe the coordinate system is relative to.
xAxisResult Vec3 A pre-allocated Vec3 in which to return the computed X axis.
yAxisResult Vec3 A pre-allocated Vec3 in which to return the computed Y axis.
zAxisResult Vec3 A pre-allocated Vec3 in which to return the computed Z axis.
Source:
Throws:
If any argument is null or undefined.
Type
ArgumentError

(static) max(value1, value2) → {Number}

Returns the maximum of two specified numbers.
Parameters:
Name Type Description
value1 Number The first value to compare.
value2 Number The second value to compare.
Source:
Returns:
The maximum of the two specified values.
Type
Number

(static) mod(number, modulus) → {Number}

Returns the integer modulus of a specified number. This differs from the % operator in that the result is always positive when the modulus is positive. For example -1 % 10 = -1, whereas mod(-1, 10) = 1.
Parameters:
Name Type Description
number Number The number whose modulus to compute.
modulus Number The modulus.
Source:
Returns:
The remainder after dividing the number by the modulus.
Type
Number

(static) normalizeAngle360(degrees) → {Number}

Restricts an angle to the range [0, 360] degrees, wrapping angles outside the range. Wrapping takes place as though traversing the edge of a unit circle; angles less than 0 wrap back to 360, while angles greater than 360 wrap back to 0.
Parameters:
Name Type Description
degrees Number the angle to wrap in degrees
Source:
Returns:
the specified angle wrapped to [0, 360] degrees
Type
Number

(static) perspectiveFrustumRectangle(viewportWidth, viewportHeight, distance) → {Rectangle}

Computes the coordinates of a rectangle carved out of a perspective projection's frustum at a given distance in model coordinates. This returns an empty rectangle if the specified distance is zero.
Parameters:
Name Type Description
viewportWidth Number The viewport width, in screen coordinates.
viewportHeight Number The viewport height, in screen coordinates.
distance Number The distance along the negative Z axis, in model coordinates.
Source:
Throws:
If the specified width or height is less than or equal to zero, or if the specified distance is negative.
Type
ArgumentError
Returns:
The frustum rectangle, in model coordinates.
Type
Rectangle

(static) perspectiveNearDistance(viewportWidth, viewportHeight, distanceToSurface) → {Number}

Computes the maximum near clip distance for a perspective projection that avoids clipping an object at a given distance from the eye point.

This computes a near clip distance appropriate for use in perspectiveFrustumRect and Matrix.setToPerspectiveProjection. The given distance should specify the smallest distance between the eye and the object being viewed, but may be an approximation if an exact distance is not required.

Parameters:
Name Type Description
viewportWidth Number The viewport width, in screen coordinates.
viewportHeight Number The viewport height, in screen coordinates.
distanceToSurface Number The distance from the perspective eye point to the nearest object, in meters.
Source:
Throws:
If the specified width or height is less than or equal to zero, or if the specified distance is negative.
Type
ArgumentError
Returns:
The maximum near clip distance, in meters.
Type
Number

(static) perspectiveNearDistanceForFarDistance(farDistance, farResolution, depthBits) → {Number}

Computes the near clip distance that corresponds to a specified far clip distance and resolution at the far clip plane. This computes a near clip distance appropriate for use in perspectiveFrustumRect and setToPerspectiveProjection. This returns zero if either the distance or the resolution are zero.
Parameters:
Name Type Description
farDistance Number The far clip distance, in meters.
farResolution Number The depth resolution at the far clip plane, in meters.
depthBits Number The number of bit-planes in the depth buffer.
Source:
Throws:
If either the distance or resolution is negative, or if the depth bits is less than one.
Type
ArgumentError
Returns:
The near clip distance, in meters.
Type
Number

(static) perspectivePixelSize(viewportWidth, viewportHeight, distance) → {Number}

Computes the vertical size of a pixel in model coordinates at a given distance from the eye point in a perspective projection. This returns zero if the specified distance is zero. The returned size is undefined if the distance is less than zero.

This method assumes the model of a screen composed of rectangular pixels, where pixel coordinates denote infinitely thin space between pixels. The units of the returned size are in model coordinates per pixel (usually meters per pixel).

Parameters:
Name Type Description
viewportWidth Number The viewport width, in screen coordinates.
viewportHeight Number The viewport height, in screen coordinates.
distance Number The distance from the perspective eye point at which to determine pixel size, in model coordinates.
Source:
Throws:
If the specified width or height is less than or equal to zero, or if the specified distance is negative.
Type
ArgumentError
Returns:
The pixel size at the specified distance from the eye point, in model coordinates per pixel.
Type
Number

(static) powerOfTwoFloor(value) → {Number}

Returns the value that is the nearest power of 2 less than or equal to the given value.
Parameters:
Name Type Description
value Number the reference value. The power of 2 returned is less than or equal to this value.
Source:
Returns:
the value that is the nearest power of 2 less than or equal to the reference value
Type
Number

(static) signum(value) → {Number}

Determine the sign of a number.
Parameters:
Name Type Description
value Number The value to determine the sign of.
Source:
Returns:
1, -1, or 0, depending on the sign of the value.
Type
Number