module Geometry.LHS ( isLHS , isRHS ) where import Geometry.Data -- | Test whether a point is stricly on the LHS of a line. -- Returns False if the line is of zero length. isLHS :: Point2 -- ^ First line point. -> Point2 -- ^ Second line point. -> Point2 -- ^ Point not on line. -> Bool {-# INLINE isLHS #-} isLHS (V2 x y) (V2 x' y') (V2 x'' y'') | (x,y) == (x',y') = False | otherwise = a1 * b2 - a2 * b1 > 0 where a1 = x' - x a2 = y' - y b1 = x'' - x b2 = y'' - y -- | Test whether a point is on the RHS of a line. -- Returns False if the line is of zero length. isRHS :: Point2 -- ^ First line point. -> Point2 -- ^ Second line point. -> Point2 -- ^ Point not on line. -> Bool {-# INLINE isRHS #-} isRHS (V2 x y) (V2 x' y') (V2 x'' y'') | (x,y) == (x',y') = False | otherwise = a1 * b2 - a2 * b1 < 0 where a1 = x' - x a2 = y' - y b1 = x'' - x b2 = y'' - y