hgeometry-1.0.0.0: Geometric Algorithms, Data structures, and Data types.
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellSafe-Inferred
LanguageGHC2021

HGeometry.Line.Class

Description

A class for types that can act as lines in d-dimensional space.

Synopsis

Documentation

class Line_ line d r | line -> d, line -> r where Source #

Types that can act as lines in d-dimensional space.

Methods

fromPointAndVec :: (Point_ point d r, Line_ line d r, Num r) => point -> Vector d r -> line Source #

Constructs a line through a point and a vector

Instances

Instances details
(Fractional r, Eq r) => Line_ (VerticalOrLineEQ r) 2 r Source # 
Instance details

Defined in HGeometry.Line.General

Methods

fromPointAndVec :: (Point_ point 2 r, Line_ (VerticalOrLineEQ r) 2 r, Num r) => point -> Vector 2 r -> VerticalOrLineEQ r Source #

Has_ Metric_ d r => Line_ (LinePV d r) d r Source # 
Instance details

Defined in HGeometry.Line.PointAndVector

Methods

fromPointAndVec :: (Point_ point d r, Line_ (LinePV d r) d r, Num r) => point -> Vector d r -> LinePV d r Source #

type Line2_ line r = (Line_ line 2 r, HyperPlane_ line 2 r) Source #

Synonym for a line-like class.

lineThrough :: forall line point d r. (Line_ line d r, Point_ point d r, Num r) => point -> point -> line Source #

Construct a line through two points.

>>> lineThrough origin (Point2 4 5) :: LinePV 2 Int
LinePV (Point2 0 0) (Vector2 4 5)

verticalLine :: forall r line. (Line_ line 2 r, Num r) => r -> line Source #

Vertical line with a given X-coordinate.

horizontalLine :: forall r line. (Line_ line 2 r, Num r) => r -> line Source #

Horizontal line with a given Y-coordinate.

class HasOnLine line d | line -> d where Source #

Types that have an onLine function that allows testing if a point lies on a line.

Methods

onLine :: (Point_ point d r, Num r, Eq r, r ~ NumType line, d ~ Dimension line) => point -> line -> Bool Source #

Test if the point lies on the line

>>> Point2 0 0 `onLine` lineThrough @(LinePV 2 Double) origin (Point2 1 0)
True
>>> Point2 10 10 `onLine` lineThrough @(LinePV 2 Double) origin (Point2 2 2)
True
>>> Point2 10 5 `onLine` lineThrough @(LinePV 2 Double) origin (Point2 2 2)
False

Instances

Instances details
HasOnLine (VerticalOrLineEQ r) 2 Source # 
Instance details

Defined in HGeometry.Line.General

Methods

onLine :: (Point_ point 2 r0, Num r0, Eq r0, r0 ~ NumType (VerticalOrLineEQ r), 2 ~ Dimension (VerticalOrLineEQ r)) => point -> VerticalOrLineEQ r -> Bool Source #

HasOnLine (LineEQ r) 2 Source # 
Instance details

Defined in HGeometry.Line.LineEQ

Methods

onLine :: (Point_ point 2 r0, Num r0, Eq r0, r0 ~ NumType (LineEQ r), 2 ~ Dimension (LineEQ r)) => point -> LineEQ r -> Bool Source #

(Has_ Metric_ d r, Fractional r, Eq (Vector d r)) => HasOnLine (LinePV d r) d Source # 
Instance details

Defined in HGeometry.Line.PointAndVector

Methods

onLine :: (Point_ point d r0, Num r0, Eq r0, r0 ~ NumType (LinePV d r), d ~ Dimension (LinePV d r)) => point -> LinePV d r -> Bool Source #

Ord r => HasOnLine (LinePV 2 r) 2 Source # 
Instance details

Defined in HGeometry.Line.PointAndVector

Methods

onLine :: (Point_ point 2 r0, Num r0, Eq r0, r0 ~ NumType (LinePV 2 r), 2 ~ Dimension (LinePV 2 r)) => point -> LinePV 2 r -> Bool Source #