Angle (angle v1.0.1)
Tired of forever converting back and forwards between degrees and radians? Well worry no more; Angle is here to make your life simple!
Magic sigils
Angle defines the ~a sigil so that you can create an Angle easily.
Examples
Creating an Angle from decimal degrees:
iex> use Angle
...> ~a(13.2)d
#Angle<13.2°>Creating an Angle from radians:
iex> use Angle
...> ~a(0.25)r
#Angle<0.25㎭>Creating an Angle from gradians:
iex> use Angle
...> ~a(40)g
#Angle<40ᵍ>Create an Angle from degrees, minutes and seconds:
iex> use Angle
...> ~a(90,30,50)dms
#Angle<90° 30′ 50″>Lazy converstion
Most functions in Angle return a potentially modified version of the angle, so that if the angle needs to be converted to radians or degrees for the underlying function to work, then it'll only be done once.
Examples
Returning the radian representation of an angle
iex> use Angle
...> ~a(13)d
...> |> Angle.to_radians()
...> |> inspect()
"{#Angle<13°>, 0.22689280275926282}"
Link to this section Summary
Functions
Convert the angle to it's absolute value by discarding complete revolutions and converting negatives.
See Angle.Trig.acos/1.
See Angle.Trig.asin/1.
See Angle.Trig.atan/1.
Initialize and Angle with zero values
Link to this section Types
maybe_number()
@type maybe_number() :: nil | number()
@type t() :: %Angle{ d: maybe_number(), dms: term(), g: maybe_number(), r: maybe_number() }
Link to this section Functions
abs(angle)
Convert the angle to it's absolute value by discarding complete revolutions and converting negatives.
Examples
iex> ~a(-270)d
...> |> Angle.abs()
#Angle<90°>
iex> ~a(-4.71238898038469)r
...> |> Angle.abs()
#Angle<1.5707963267948966㎭>
iex> ~a(-270,15,45)dms
...> |> Angle.abs()
#Angle<90° 45′ 15″>
iex> ~a(-300)g
...> |> Angle.abs()
#Angle<100ᵍ>
acos(x)
See Angle.Trig.acos/1.
acosh(x)
See Angle.Trig.acosh/1.
asin(x)
See Angle.Trig.asin/1.
asinh(x)
See Angle.Trig.asinh/1.
atan2(x, y)
See Angle.Trig.atan2/2.
atan(x)
See Angle.Trig.atan/1.
cos(angle)
See Angle.Trig.cos/1.
cosh(angle)
See Angle.Trig.cosh/1.
degrees(n)
See Angle.Degree.init/1.
dms(d, m, s)
See Angle.DMS.init/3.
gradians(n)
See Angle.Gradian.init/1.
radians(n)
See Angle.Radian.init/1.
sin(angle)
See Angle.Trig.sin/1.
sinh(angle)
See Angle.Trig.sinh/1.
tan(angle)
See Angle.Trig.tan/1.
tanh(angle)
See Angle.Trig.tanh/1.
to_degrees(angle)
to_dms(angle)
See Angle.DMS.to_dms/1.
to_gradians(angle)
to_radians(angle)
zero()
@spec zero() :: t()
Initialize and Angle with zero values
Examples
iex> Angle.zero()
#Angle<0>