--------------------------------------------------------------------------------
-- |
-- Module      :  HGeometry.Point.Orientation
-- Copyright   :  (C) Frank Staals
-- License     :  see the LICENSE file
-- Maintainer  :  Frank Staals
--
-- orientation tests
--
--------------------------------------------------------------------------------
module HGeometry.Point.Orientation
  ( CCW(CCW,CW,CoLinear)
  , ccw
  , isCoLinear

  , sortAround

  , ccwCmpAroundWith
  , cwCmpAroundWith
  , ccwCmpAround
  , cwCmpAround

  , insertIntoCyclicOrder

  , cmpInDirection2
  ) where

import HGeometry.Point.Class
import HGeometry.Point.Orientation.Degenerate
import HGeometry.Vector

-- | Comparison that compares which point is 'larger' in the direction given by
-- the vector u.
cmpInDirection2       :: (Num r, Ord r, Point_ point 2 r)
                     => Vector 2 r -> point -> point -> Ordering
cmpInDirection2 :: forall r point.
(Num r, Ord r, Point_ point 2 r) =>
Vector 2 r -> point -> point -> Ordering
cmpInDirection2 Vector 2 r
u point
p point
q = Vector 2 r
u Vector 2 r -> Vector 2 r -> r
forall vector (d :: Nat) r.
(Metric_ vector d r, Num r) =>
vector -> vector -> r
`dot` (point
p point -> point -> Vector 2 r
forall point (d :: Nat) r.
(Affine_ point d r, Num r) =>
point -> point -> Vector d r
.-. point
q) r -> r -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` r
0