Safe Haskell | None |
---|
A bearing in degrees between 0 and 360.
- data Bearing
- class HasBearing t where
- modBearing :: Double -> Bearing
- degreeBearing :: Prism' Double Bearing
- radianBearing :: Prism' Double Bearing
Documentation
class HasBearing t whereSource
modBearing :: Double -> BearingSource
Construct a bearing such that if the given value is out of bounds, a modulus is taken to keep it within 0 inclusive and 360 exclusive.
>>>
modBearing 7
Bearing 7.0000
>>>
modBearing 0
Bearing 0.0000
>>>
modBearing (-0.0001)
Bearing 359.9999
>>>
modBearing 360
Bearing 0.0000
>>>
modBearing 359.99999
Bearing 360.0000
>>>
modBearing 359.999
Bearing 359.9990
degreeBearing :: Prism' Double BearingSource
A prism on bearing to a double between 0 inclusive and 360 exclusive.
>>>
7 ^? degreeBearing
Just (Bearing 7.0000)
>>>
0 ^? degreeBearing
Just (Bearing 0.0000)
>>>
359 ^? degreeBearing
Just (Bearing 359.0000)
>>>
359.997 ^? degreeBearing
Just (Bearing 359.9970)
>>>
360 ^? degreeBearing
Nothing
all (\m -> degreeBearing # m == n) (n ^? degreeBearing)
radianBearing :: Prism' Double BearingSource
A prism on bearing to a double between 0 and π exclusive.
>>>
(2 * pi - 0.0000000001) ^? radianBearing
Just (Bearing 360.0000)
>>>
0 ^? radianBearing
Just (Bearing 0.0000)
>>>
0.001 ^? radianBearing
Just (Bearing 0.0573)
>>>
1.78391 ^? radianBearing
Just (Bearing 102.2105)
>>>
pi ^? radianBearing
Just (Bearing 180.0000)
>>>
(2 * pi) ^? radianBearing
Nothing
>>>
(-0.001) ^? radianBearing
Nothing