Geo.Turf.Math (geo_turf v0.3.0)
All sorts of mathematical functions
Summary
Types
Link to this type
imperial_length()
@type imperial_length() :: :miles | :nauticalmiles | :inches | :yards | :feet
Link to this type
length_unit()
@type length_unit() :: si_length_uk() | si_length_us() | imperial_length()
Link to this type
si_length_uk()
@type si_length_uk() :: :meters | :kilometers | :centimeters | :millimeters
Link to this type
si_length_us()
@type si_length_us() :: :metres | :kilometres | :centimetres | :millimetres
Functions
Link to this function
bearing_to_azimuth(bearing)
Link to this function
convert_area(area, from \\ :meters, to \\ :kilometers)
@spec convert_area(number(), length_unit(), length_unit()) :: number()
Link to this function
convert_length(length, from \\ :kilometers, to \\ :kilometers)
@spec convert_length(number(), length_unit(), length_unit()) :: number()
Link to this function
degrees_to_radians(degrees)
Link to this function
length_to_degrees(length, units \\ :kilometers)
@spec length_to_degrees(number(), length_unit()) :: float()
Link to this function
length_to_radians(length, unit \\ :kilometers)
@spec length_to_radians(number(), length_unit()) :: float()
Link to this function
mod(number, modulus)
Calculates the modulo of a number (integer or float).
Note that this function uses floored division
whereas the builtin rem
function uses truncated division
. See Decimal.rem/2
if you want a
truncated division
function for Decimals that will return the same value as
the BIF rem/2
but in Decimal form.
See Wikipedia for an explanation of the difference.
Taken from cldr_utils with thanks and gratitude.
Examples
iex> Geo.Turf.Math.mod(1234.0, 5)
4.0
Link to this function
radians_to_degrees(radians)
Link to this function
radians_to_length(radians, unit \\ :kilometers)
@spec radians_to_length(number(), length_unit()) :: number()
Link to this function
rounded(number, precision \\ 0)
Round number to precision
Example
iex> Geo.Turf.Math.rounded(120.4321)
120
iex> Geo.Turf.Math.rounded(120.4321, 3)
120.432