blob: 82fd7e05c0472fd9d317ed7c8f50637cfdca5b26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module Spear.Math.Segment
(
Segment(..)
, seglr
)
where
import Spear.Math.Utils
import Spear.Math.Vector
-- | A line segment in 2D space.
data Segment = Segment {-# UNPACK #-} !Vector2 {-# UNPACK #-} !Vector2
-- | Classify the given point's position with respect to the given segment.
seglr :: Segment -> Vector2 -> Side
seglr (Segment p0 p1) p
| orientation2d p0 p1 p < 0 = R
| otherwise = L
|