Commit before attempting to allow for non-convex chasm shapes
This commit is contained in:
+42
-31
@@ -1,40 +1,51 @@
|
||||
module Geometry.LHS
|
||||
( isLHS
|
||||
, isRHS
|
||||
) where
|
||||
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
|
||||
|
||||
{- | Test whether a point is stricly on the LHS of a line.
|
||||
Returns False if the line is of zero length.
|
||||
-}
|
||||
isLHS ::
|
||||
-- | First line point.
|
||||
Point2 ->
|
||||
-- | Second line point.
|
||||
Point2 ->
|
||||
-- | Point not on line.
|
||||
Point2 ->
|
||||
Bool
|
||||
{-# INLINE isLHS #-}
|
||||
isLHS (V2 x y) (V2 x' y') (V2 x'' y'')
|
||||
| (x,y) == (x',y') = False
|
||||
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
|
||||
|
||||
{- | Test whether a point is on the RHS of a line.
|
||||
Returns False if the line is of zero length.
|
||||
-}
|
||||
isRHS ::
|
||||
-- | First line point.
|
||||
Point2 ->
|
||||
-- | Second line point.
|
||||
Point2 ->
|
||||
-- | Point not on line.
|
||||
Point2 ->
|
||||
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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user