hcg-minus-0.14: haskell cg (minus)

Safe HaskellSafe-Inferred

Data.CG.Minus.Bearing

Description

Compass bearings.

Synopsis

Documentation

data Bearing Source

Enumeration of compass bearings

Constructors

N 
NNE 
NE 
ENE 
E 
ESE 
SE 
SSE 
S 
SSW 
SW 
WSW 
W 
WNW 
NW 
NNW 

bearing :: Pt R -> Pt R -> BearingSource

Bearing from Pt p to q.

 let f (x,y) = bearing (Pt 0 0) (Pt x y)
 map f [(0,1),(1,1),(1,0),(1,-1)] == [N,NE,E,SE]
 map f [(0,-1),(-1,-1),(-1,0),(-1,1)] == [S,SW,W,NW]
 map f [(1/4,1),(1,1/4),(1,-1/4),(1/4,-1)] == [NNE,ENE,ESE,SSE]
 map f [(-1/4,-1),(-1,-1/4),(-1,1.4),(-1/4,1)] == [SSW,WSW,NW,NNW]

bearing_8 :: Pt R -> Pt R -> BearingSource

Bearing to nearest eight point compass bearing

 let f (x,y) = bearing_8 (Pt 0 0) (Pt x y)
 map f [(1/4,1),(1,1/4),(1,-1/4),(1/4,-1)] == [N,E,E,S]

bearing_opposite :: (Bearing, Bearing) -> BoolSource

Predicate that is True if bearings are opposite.

 bearing_opposite (NW,SE) == True
 map bearing_opposite (zip [N,E,S,W] [S,W,N,E]) == [True,True,True,True]