This namespace contains definitions for static functions that make it easy some math calculations.
- Source:
- bu/math/math.jsdoc
Methods
-
<static> bearing(point1, point2)
-
Calculates the bearing between two points in lonlat EPSG:4326 projection. The bearing is calculated at the first point and in decimal degrees. Inspired by: https://www.movable-type.co.uk/scripts/latlong.html
Parameters:
Name Type Description point1
bu.Coordinate First point.
point2
bu.Coordinate Second point.
- Source:
- bu/math/math.js
Returns:
- Type
- number
-
<static> changeVectorNorm(x, y, n, result)
-
Changes the vector normal.
Parameters:
Name Type Description x
number Coord X.
y
number Coord Y.
n
number Normalization.
result
Array.<number> The two values of the result.
- Source:
- bu/math/math.js
-
<static> clamp(value, min, max)
-
Return a value between limits.
Parameters:
Name Type Description value
number Number to limit.
min
number Minimum value.
max
number Maximum value.
- Source:
- bu/math/math.js
Returns:
Limited value.
- Type
- number
-
<static> clampAngle(angle [, isRadian] [, toPI] [, toRadian])
-
Return a decimal degree clamped to [0.0, 360.0) or [-180.0, 180.0] values, or their equivalent in radians.
Parameters:
Name Type Argument Description angle
number Angle to clamp.
isRadian
boolean <optional>
If the passed angle is a radian. If it is omited the angle param is considered decimal.
toPI
boolean <optional>
If the returned value must be clamped to [-180.0, 180.0]. If it is omited angles are returned in [0.0, 360.0) range.
toRadian
boolean <optional>
If returned value must be radians. If omited returns decimal degrees.
- Source:
- bu/math/math.js
Returns:
Angle clampled.
- Type
- number
-
<static> decreaseAbs(num, dec)
-
Moves a value towards zero value.
Parameters:
Name Type Description num
number Number to move.
dec
number Quantity to move towards zero.
- Source:
- bu/math/math.js
Returns:
Zero or the new value.
- Type
- number
-
<static> ECEFToLatLon(y, z, x)
-
Transforms one coordinate in ECEF to geographic projection. Relation between threejs and ECEF ThreeJS --> x, y, z ECEF --> y, z, x
|y-->z | | | +---------- / x-->y / / / z-->x
Parameters:
Name Type Description y
number Coordinate Y.
z
number Coordinate Z.
x
number Coordinate X.
- Source:
- bu/math/math.js
Returns:
Coordinate as [longitude, latitude, elev].
- Type
- bu.Coordinate
-
<static> getDistance(coordinates)
-
Return the total distance of the linestring given by its coordinates.
Parameters:
Name Type Description coordinates
Array.<bu.Coordinate> The coordinates.
- Source:
- bu/math/math.js
Returns:
The distance.
- Type
- number
-
<static> getDistanceOnEarth(coordinate1, coordinate2)
-
Calculates distance in meters from one point to other of Earth. Calculation is aproximated using mean radius spherical Earth.
Parameters:
Name Type Description coordinate1
bu.Coordinate Coordinate as longitude and latitude, i.e. an array with longitude as 1st and latitude as 2nd element.
coordinate2
bu.Coordinate Coordinate as longitude and latitude, i.e. an array with longitude as 1st and latitude as 2nd element.
- Source:
- bu/math/math.js
Returns:
Distance in meters.
- Type
- number
-
<static> getTopCoordinate(coordinates)
-
Return the coordinate with the top Z value. Coordinates are in local space, so the Z value are Y values (as in WebGL).
Parameters:
Name Type Description coordinates
Array.<bu.Coordinate> The local coordinates.
- Source:
- bu/math/math.js
Returns:
The coordinate.
- Type
- bu.Coordinate
-
<static> getVerticalArea(coordinates)
-
Return the area of an array of vertical and coplanar coordinates. The first and last coordinate must be the same. Inspired by: http://geomalgorithms.com/a01-_area.html
Parameters:
Name Type Description coordinates
Array.<bu.Coordinate> The coordinates.
- Source:
- bu/math/math.js
Returns:
The area.
- Type
- number
-
<static> latLonToECEF(longitude, latitude, elev)
-
Transforms one coordinate in geographical projection to ECEF.
Parameters:
Name Type Description longitude
number Longitude of the coordinate we want to transform.
latitude
number Longitude of the coordinate we want to transform.
elev
number Elevation.
- Source:
- bu/math/math.js
Returns:
Coordinate as [x, y, z].
- Type
- bu.Coordinate
-
<static> latLonToMercatorSpheric(longitude, latitude)
-
Transforms one coordinate in geographical projection to spherical mercator.
Parameters:
Name Type Description longitude
number Longitude of the coordinate we want to transform.
latitude
number Longitude of the coordinate we want to transform.
- Source:
- bu/math/math.js
Returns:
Coordinate as longitude and latitude.
- Type
- bu.Coordinate
-
<static> maxFriction(friction, velocityX, velocityY, maxFrictionTime, result)
-
Calculates the maximum friction.
Parameters:
Name Type Description friction
number Friction.
velocityX
number Velocity in X coord.
velocityY
number Velocity in Y coord.
maxFrictionTime
number Maximum friction time.
result
Array.<number> The two values of the result.
- Source:
- bu/math/math.js
-
<static> mercatorSphericToLatLon(longitude, latitude)
-
Transforms one coordinate in spherical mercator projection to geographical.
Parameters:
Name Type Description longitude
number Longitude of the coordinate we want to transform.
latitude
number Longitude of the coordinate we want to transform.
- Source:
- bu/math/math.js
Returns:
Coordinate as longitude and latitude.
- Type
- bu.Coordinate
-
<static> mod(dividend, divisor)
-
Modulo operation
Parameters:
Name Type Description dividend
number Dividend.
divisor
number Divisor.
- Source:
- bu/math/math.js
Returns:
Value in range
[0,divisor[
- Type
- number
-
<static> real(value)
-
Checks if a value is a real number. Not NaN or Infinity.
Parameters:
Name Type Description value
number Number to check.
- Source:
- bu/math/math.js
Returns:
True if number is a real number.
- Type
- boolean