All sorts of mathematical functions
Summary
Types
@type imperial_length() :: :miles | :nauticalmiles | :inches | :yards | :feet
@type length_unit() :: si_length_uk() | si_length_us() | imperial_length()
@type si_length_uk() :: :meters | :kilometers | :centimeters | :millimeters
@type si_length_us() :: :metres | :kilometres | :centimetres | :millimetres
Functions
@spec convert_area(number(), length_unit(), length_unit()) :: number()
@spec convert_length(number(), length_unit(), length_unit()) :: number()
@spec length_to_degrees(number(), length_unit()) :: float()
@spec length_to_radians(number(), length_unit()) :: float()
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
@spec radians_to_length(number(), length_unit()) :: number()
Round number to precision
Example
iex> Geo.Turf.Math.rounded(120.4321)
120
iex> Geo.Turf.Math.rounded(120.4321, 3)
120.432