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 point1bu.Coordinate First point.
point2bu.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 xnumber Coord X.
ynumber Coord Y.
nnumber Normalization.
resultArray.<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 valuenumber Number to limit.
minnumber Minimum value.
maxnumber 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 anglenumber Angle to clamp.
isRadianboolean <optional>
If the passed angle is a radian. If it is omited the angle param is considered decimal.
toPIboolean <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.
toRadianboolean <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 numnumber Number to move.
decnumber 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-->xParameters:
Name Type Description ynumber Coordinate Y.
znumber Coordinate Z.
xnumber 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 coordinatesArray.<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 coordinate1bu.Coordinate Coordinate as longitude and latitude, i.e. an array with longitude as 1st and latitude as 2nd element.
coordinate2bu.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 coordinatesArray.<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 coordinatesArray.<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 longitudenumber Longitude of the coordinate we want to transform.
latitudenumber Longitude of the coordinate we want to transform.
elevnumber 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 longitudenumber Longitude of the coordinate we want to transform.
latitudenumber 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 frictionnumber Friction.
velocityXnumber Velocity in X coord.
velocityYnumber Velocity in Y coord.
maxFrictionTimenumber Maximum friction time.
resultArray.<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 longitudenumber Longitude of the coordinate we want to transform.
latitudenumber 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 dividendnumber Dividend.
divisornumber 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 valuenumber Number to check.
- Source:
- bu/math/math.js
Returns:
True if number is a real number.
- Type
- boolean
Javascript API 7.x