Commit before attempting to allow for non-convex chasm shapes

This commit is contained in:
2025-10-05 15:06:19 +01:00
parent b3924fb8b8
commit 43db5a2ebc
25 changed files with 333 additions and 303 deletions
+42 -31
View File
@@ -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