Angle.Gradian (angle v1.0.1)

Functions relating to dealing with angles in Gradians.

Link to this section Summary

Functions

Convert the angle to it's absolute value by discarding complete revolutions and converting negatives.

Ensure that a gradian representation is present for this angle, otherwise calculate one.

Initialize an Angle from a number n of gradians

Attempt to arse decimal gradians.

Return the gradians representation of the Angle.

Link to this section Functions

@spec abs(Angle.t()) :: Angle.t()

Convert the angle to it's absolute value by discarding complete revolutions and converting negatives.

Examples

iex> ~a(-300)g
...> |> Angle.Gradian.abs()
#Angle<100>

iex> ~a(1300)g
...> |> Angle.Gradian.abs()
#Angle<100>
@spec ensure(Angle.t()) :: Angle.t()

Ensure that a gradian representation is present for this angle, otherwise calculate one.

Examples

iex> ~a(90)d
...> |> ensure()
...> |> Map.get(:g)
100.0

iex> ~a(1)r
...> |> ensure()
...> |> Map.get(:g)
63.66197723675813

iex> ~a(90 0 0)dms
...> |> ensure()
...> |> Map.get(:g)
100.0
@spec init(number()) :: Angle.t()

Initialize an Angle from a number n of gradians

Examples

iex> init(13)
#Angle<13>

iex> init(13.2)
#Angle<13.2>

iex> init(0)
#Angle<0>

iex> init(0.0)
#Angle<0>
@spec parse(String.t()) :: {:ok, Angle.t()} | {:error, term()}

Attempt to arse decimal gradians.

Examples

iex> "13" |> parse() |> inspect()
"{:ok, #Angle<13ᵍ>}"

iex> "13.2" |> parse() |> inspect()
"{:ok, #Angle<13.2ᵍ>}"

iex> "13ᵍ" |> parse() |> inspect()
"{:ok, #Angle<13ᵍ>}"

iex> "13.2ᵍ" |> parse() |> inspect()
"{:ok, #Angle<13.2ᵍ>}"
Link to this function

to_gradians(angle)

@spec to_gradians(Angle.t()) :: {Angle.t(), number()}

Return the gradians representation of the Angle.

Examples

iex> use Angle
...> ~a(0.5)r
...> |> to_gradians()
...> |> inspect()
"{#Angle<0.5㎭>, 31.830988618379067}"