An Angle represents an angle in degrees, radians, or turns. It is stored
as a number of radians.
Construct an angle from a number of radians.
Convert an angle to a number of radians.
Construct an angle from a number of degrees.
Angle.degrees 180
--> Angle.radians piConvert an angle to a number of degrees.
Angle.turns 2 |> Angle.inDegrees
--> 720Construct an angle from a number of turns.
Angle.turns -0.25
--> Angle.degrees -90Convert an angle to a number of turns.
Angle.radians pi |> Angle.inTurns
--> 0.5Angles are sometimes measured in degrees, minutes, and seconds, where 1 minute = 1/60th of a degree and 1 second = 1/60th of a minute.
Construct an angle from a number of minutes.
Angle.minutes 30
--> Angle.degrees 0.5Convert an angle to a number of minutes.
Angle.degrees 2 |> Angle.inMinutes
--> 120Construct an angle from a number of seconds.
Angle.seconds 120
--> Angle.minutes 2Convert an angle to a number of seconds.
Angle.degrees 0.1 |> Angle.inSeconds
--> 360Degrees, minutes and seconds are often used together, so a couple of special functions are provided to convert to and from combinations of those units.
The sign of an angle given in degrees, minutes and seconds.
Construct an angle given its sign and its degree, minute and second
components. The signs of degrees, minutes and seconds will be ignored
(their absolute values will be used). Note that only seconds may be
fractional! In general minutes and seconds should each be less than 60, but
this is not enforced.
Angle.fromDms
{ sign = Angle.Positive
, degrees = 45
, minutes = 30
, seconds = 36
}
--> Angle.degrees 45.51
Angle.fromDms
{ sign = Angle.Negative
, degrees = 2
, minutes = 15
, seconds = 0
}
--> Angle.degrees -2.25Convert an angle to a number of degrees, minutes and seconds, along with its
sign. The degrees, minutes and seconds values will all be non-negative,
and both minutes and seconds will be less than 60.
Angle.toDms (Angle.degrees 1.5)
--> { sign = Angle.Positive
--> , degrees = 1
--> , minutes = 30
--> , seconds = 0
--> }
Angle.toDms (Angle.degrees -0.751)
--> { sign = Angle.Negative
--> , degrees = 0
--> , minutes = 45
--> , seconds = 3.6
--> }You could use this to write a string-conversion function for angles, something like:
angleString angle =
let
{ sign, degrees, minutes, seconds } =
Angle.toDms angle
signString =
case sign of
Angle.Positive ->
""
Angle.Negative ->
"-"
in
String.concat
[ signString
, String.fromInt degrees
, "° "
, String.fromInt minutes
, "′ "
, Round.round 3 seconds
, "″"
](Here we're using the myrho/elm-round package to control the number of decimal places used when displaying the number of seconds.)
If you're using Angle values instead of plain Floats, you'll need to use
these functions instead of the corresponding ones in core.
Shorthand for Angle.radians 1, Angle.degrees 1 etc. Can be convenient to use
with Quantity.per.