Angle difference between two bearings: Difference between revisions

Content deleted Content added
Hout (talk | contribs)
m →‎JS ES6: Layout, function name
Hout (talk | contribs)
m →‎{{header|Haskell}}: (layout, function name, narrowed import)
Line 185:
 
=={{header|Haskell}}==
<lang Haskell>import Text.Printf (printf)
 
<lang Haskell>import Text.Printf
 
type Radians = Float
Line 193 ⟶ 192:
 
angleBetweenDegrees :: Degrees -> Degrees -> Degrees
angleBetweenDegrees a b = degrees $ relBearingbearingDelta (radians a) (radians b)
 
relBearingbearingDelta :: Radians -> Radians -> Radians
relBearingbearingDelta a b -- sign * dot-product
= sign * acos ((ax * bx) + (ay * by))
where
Line 213 ⟶ 212:
radians = (/ 180) . (pi *)
 
-- TEST -----------------------------------------------------------------------
main :: IO ()
main =
Line 227:
displayRow (x, y) =
printf "%6.2f° + %6.2f° -> %7.2f°" x y $ angleBetweenDegrees x y</lang>
 
{{Out}}
<pre> 20.00° + 45.00° -> 25.00°