Angle.Degree (angle v1.0.1)

Functions relating to dealing with angles in real Degrees.

Link to this section Summary

Functions

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

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

Initialize an Angle from a number n of degrees

Attempt to parse decimal degrees.

Return the degrees 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(-270)d
...> |> Angle.Degree.abs()
#Angle<90°>

iex> ~a(1170)d
...> |> Angle.Degree.abs()
#Angle<90°>
@spec ensure(Angle.t()) :: Angle.t()

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

Examples

iex> ~a(0.5)r
...> |> ensure()
...> |> Map.get(:d)
28.64788975654116

iex> ~a(76.3944)g
...> |> ensure()
...> |> Map.get(:d)
68.75496000000001

iex> ~a(77 50 56)dms
...> |> ensure()
...> |> Map.get(:d)
77.84888888888888
@spec init(number()) :: Angle.t()

Initialize an Angle from a number n of degrees

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 parse decimal degrees.

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°>}"

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

to_degrees(angle)

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

Return the degrees representation of the Angle.

Examples

iex> ~a(0.5)r
...> |> to_degrees()
...> |> inspect()
"{#Angle<28.64788975654116°>, 28.64788975654116}"