blob: a89ee0580cbd7fb6a66985af489c19dc81539a94 (
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.Vector2
-- | 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
|