Copyright | (c) 2018 Cedric Liegeois |
---|---|
License | BSD3 |
Maintainer | Cedric Liegeois <ofmooseandmen@yahoo.fr> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Types and functions for working with angles representing latitudes, longitude and bearings.
Synopsis
- data Angle
- decimalDegrees :: Double -> Angle
- dms :: Int -> Int -> Int -> Int -> Angle
- dmsE :: Int -> Int -> Int -> Int -> Either String Angle
- dmsF :: MonadFail m => Int -> Int -> Int -> Int -> m Angle
- arcLength :: Angle -> Length -> Length
- central :: Length -> Length -> Angle
- isNegative :: Angle -> Bool
- isWithin :: Angle -> Angle -> Angle -> Bool
- negate' :: Angle -> Angle
- normalise :: Angle -> Angle -> Angle
- asin' :: Double -> Angle
- atan2' :: Double -> Double -> Angle
- cos' :: Angle -> Double
- sin' :: Angle -> Double
- getDegrees :: Angle -> Int
- getMinutes :: Angle -> Int
- getSeconds :: Angle -> Int
- getMilliseconds :: Angle -> Int
- toDecimalDegrees :: Angle -> Double
- angle :: ReadP Angle
- readAngle :: String -> Angle
- readAngleE :: String -> Either String Angle
- readAngleF :: MonadFail m => String -> m Angle
The Angle
type
An angle with a resolution of a milliseconds of a degree. When used as a latitude/longitude this roughly translate to a precision of 30 millimetres at the equator.
Smart constructors
decimalDegrees :: Double -> Angle Source #
Calculations
arcLength :: Angle -> Length -> Length Source #
arcLength a r
computes the Length
of the arc that subtends the angle a
for radius r
.
central :: Length -> Length -> Angle Source #
central l r
computes the central Angle
from the arc length l
and radius r
.
isWithin :: Angle -> Angle -> Angle -> Bool Source #
Is given Angle
within range [low
..high
] inclusive?
Trigonometric functions
atan2' :: Double -> Double -> Angle Source #
atan2' y x
computes the Angle
(from the positive x-axis) of the vector from the origin to the point (x,y).
Accessors
getDegrees :: Angle -> Int Source #
getDegrees a
returns the degree component of a
.
getMinutes :: Angle -> Int Source #
getMinutes a
returns the minute component of a
.
getSeconds :: Angle -> Int Source #
getSeconds a
returns the second component of a
.
getMilliseconds :: Angle -> Int Source #
getMilliseconds a
returns the milliseconds component of a
.
Read
readAngle :: String -> Angle Source #
Obtains a Angle
from the given string formatted as either:
- d°m′s.ms″ - e.g. 55°36'21.3", where minutes, seconds and milliseconds are optional.
- decimal° - e.g. 55.6050° or -133°
Symbols:
- degree: ° or d
- minute: ', ′ or m
- second: ", ″, '' or s
This simply calls read s :: Angle
so error
should be handled at the call site.