hgeometry-point
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageGHC2024

HGeometry.Point.Orientation

Description

orientation tests

Synopsis

Documentation

data CCW where Source #

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.

Instances

Instances details
Show CCW Source # 
Instance details

Defined in HGeometry.Point.Orientation.Degenerate

Eq CCW Source # 
Instance details

Defined in HGeometry.Point.Orientation.Degenerate

Methods

(==) :: CCW -> CCW -> Bool Source #

(/=) :: CCW -> CCW -> Bool Source #

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.

cmpInDirection2 :: (Num r, Ord r, Point_ point 2 r) => Vector 2 r -> point -> point -> Ordering Source #

Comparison that compares which point is larger in the direction given by the vector u.