aboutsummaryrefslogtreecommitdiff
path: root/Spear/Math/Segment.hs
blob: c632838ed816addc91fa7954c8e27b4c574b5d85 (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