| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Point.Orientation
Description
orientation tests
Synopsis
- data CCW where
- ccw :: (Point_ point 2 r, Point_ point' 2 r, Point_ point'' 2 r, Num r, Ord r) => point -> point' -> point'' -> CCW
- isCoLinear :: (Point_ point 2 r, Num r, Eq r) => point -> point -> point -> Bool
- sortAround :: (Point_ center 2 r, Point_ point 2 r, Num r, Ord r) => center -> [point] -> [point]
- ccwCmpAroundWith :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => Vector 2 r -> center -> point -> point -> Ordering
- cwCmpAroundWith :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => Vector 2 r -> center -> point -> point -> Ordering
- ccwCmpAround :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => center -> point -> point -> Ordering
- cwCmpAround :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => center -> point -> point -> Ordering
- insertIntoCyclicOrder :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => center -> point -> CList point -> CList point
- cmpInDirection2 :: (Num r, Ord r, Point_ point 2 r) => Vector 2 r -> point -> point -> Ordering
Documentation
Data type for expressing the orientation of three points, with the option of allowing Colinearities.
Bundled Patterns
| pattern CCW :: CCW | CounterClockwise orientation. Also called a left-turn. |
| pattern CW :: CCW | Clockwise orientation. Also called a right-turn. |
| pattern CoLinear :: CCW | CoLinear orientation. Also called a straight line. |
ccw :: (Point_ point 2 r, Point_ point' 2 r, Point_ point'' 2 r, Num r, Ord r) => point -> point' -> point'' -> CCW Source #
Given three points p q and r determine the orientation when going from p to r via q.
Be wary of numerical instability: >>> ccw (Point2 0 0.3) (Point2 1 0.6) (Point2 2 (0.9::Double)) CCW
>>>ccw (Point2 0 0.3) (Point2 1 0.6) (Point2 2 (0.9::Rational))CoLinear
isCoLinear :: (Point_ point 2 r, Num r, Eq r) => point -> point -> point -> Bool Source #
Given three points p q and r determine if the line from p to r via q is straight/colinear.
This is identical to `ccw p q r == CoLinear` but doesn't have the Ord constraint.
sortAround :: (Point_ center 2 r, Point_ point 2 r, Num r, Ord r) => center -> [point] -> [point] Source #
Sort the points arround the given point p in counter clockwise order with respect to the rightward horizontal ray starting from p. If two points q and r are colinear with p, the closest one to p is reported first.
\( O(n log n) \)
ccwCmpAroundWith :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => Vector 2 r -> center -> point -> point -> Ordering Source #
Given a zero vector z, a center c, and two points p and q, compute the ccw ordering of p and q around c with this vector as zero direction.
pre: the points p,q /= c
cwCmpAroundWith :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => Vector 2 r -> center -> point -> point -> Ordering Source #
Given a zero vector z, a center c, and two points p and q, compute the cw ordering of p and q around c with this vector as zero direction.
pre: the points p,q /= c
ccwCmpAround :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => center -> point -> point -> Ordering Source #
Counter clockwise ordering of the points around c. Points are ordered with respect to the positive x-axis.
cwCmpAround :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => center -> point -> point -> Ordering Source #
Clockwise ordering of the points around c. Points are ordered with respect to the positive x-axis.
insertIntoCyclicOrder :: (Point_ center 2 r, Point_ point 2 r, Ord r, Num r) => center -> point -> CList point -> CList point Source #
\( O(n) \) Given a center c, a new point p, and a list of points ps, sorted in counter clockwise order around c. Insert p into the cyclic order. The focus of the returned cyclic list is the new point p.