| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Line
Contents
Description
Lines in d-dimensional space.
Synopsis
- module HGeometry.Line.Class
- module HGeometry.Line.LineEQ
- anchorPoint :: forall (d :: Nat) r f. Functor f => (Point d r -> f (Point d r)) -> LinePV d r -> f (LinePV d r)
- bisector :: (Fractional r, Point_ point 2 r) => point -> point -> LinePV 2 r
- cmpSlope :: (Num r, Ord r) => LinePV 2 r -> LinePV 2 r -> Ordering
- fromLinearFunction :: Num r => r -> r -> LinePV 2 r
- isIdenticalTo :: forall (d :: Nat) r. Eq (Vector d r) => LinePV d r -> LinePV d r -> Bool
- isPerpendicularTo :: (Num r, Eq r) => Vector 2 r -> LinePV 2 r -> Bool
- leftHalfPlane :: (Num r, Ord r) => LinePV 2 r -> HalfSpaceF (LinePV 2 r)
- onSide :: (Ord r, Num r, Point_ point 2 r) => point -> LinePV 2 r -> SideTest
- perpendicularTo :: Num r => LinePV 2 r -> LinePV 2 r
- rightHalfPlane :: (Num r, Ord r) => LinePV 2 r -> HalfSpaceF (LinePV 2 r)
- toLinearFunction :: (Fractional r, Ord r) => LinePV 2 r -> Maybe (LineEQ r)
- class HasDirection t where
- class HasSupportingLine t where
- supportingLine :: t -> LinePV (Dimension t) (NumType t)
- data LinePV (d :: Nat) r = LinePV {
- _anchorPoint :: !(Point d r)
- _direction :: !(Vector d r)
- class OnSideUpDownTest t where
- onSideUpDown :: forall (d :: Nat) r point. (d ~ Dimension t, r ~ NumType t, Ord r, Num r, Point_ point d r) => point -> t -> SideTestUpDown
- data SideTest
- data SideTestUpDown
- module HGeometry.Line.General
- type LineLineIntersection line = LineLineIntersectionG (NumType line) line
- data LineLineIntersectionG r line
- = Line_x_Line_Point (Point 2 r)
- | Line_x_Line_Line line
- fromLineEQ :: Num r => LineEQ r -> LinePV 2 r
Documentation
module HGeometry.Line.Class
module HGeometry.Line.LineEQ
anchorPoint :: forall (d :: Nat) r f. Functor f => (Point d r -> f (Point d r)) -> LinePV d r -> f (LinePV d r) Source #
Lens to access the anchor point of the line
bisector :: (Fractional r, Point_ point 2 r) => point -> point -> LinePV 2 r Source #
Get the bisector between two points
cmpSlope :: (Num r, Ord r) => LinePV 2 r -> LinePV 2 r -> Ordering Source #
Compares the lines on slope. Vertical lines are considered larger than anything else.
>>>(LinePV origin (Vector2 5 1)) `cmpSlope` (LinePV origin (Vector2 3 3))LT>>>(LinePV origin (Vector2 5 1)) `cmpSlope` (LinePV origin (Vector2 (-3) 3))GT>>>(LinePV origin (Vector2 5 1)) `cmpSlope` (LinePV origin (Vector2 0 1))LT
fromLinearFunction :: Num r => r -> r -> LinePV 2 r Source #
Create a line from the linear function ax + b
isIdenticalTo :: forall (d :: Nat) r. Eq (Vector d r) => LinePV d r -> LinePV d r -> Bool Source #
Test if two lines are identical, meaning; if they have exactly the same anchor point and directional vector.
isPerpendicularTo :: (Num r, Eq r) => Vector 2 r -> LinePV 2 r -> Bool Source #
Test if a vector is perpendicular to the line.
leftHalfPlane :: (Num r, Ord r) => LinePV 2 r -> HalfSpaceF (LinePV 2 r) Source #
Given the oriented line, computes the halfspace left of the line.
onSide :: (Ord r, Num r, Point_ point 2 r) => point -> LinePV 2 r -> SideTest Source #
Given a point q and a line l, compute to which side of l q lies. For vertical lines the left side of the line is interpeted as below.
>>>Point2 10 10 `onSide` (lineThrough origin $ Point2 10 5)LeftSide>>>Point2 10 10 `onSide` (lineThrough origin $ Point2 (-10) 5)RightSide>>>Point2 5 5 `onSide` (verticalLine 10)LeftSide>>>Point2 5 5 `onSide` (lineThrough origin $ Point2 (-3) (-3))OnLine
perpendicularTo :: Num r => LinePV 2 r -> LinePV 2 r Source #
Given a line l with anchor point p and vector v, get the line m perpendicular to l that also goes through p. The line is oriented *into* the right halfplane of l.
>>>perpendicularTo $ LinePV (Point2 3 4) (Vector2 (-1) 2)LinePV (Point2 3 4) (Vector2 2 1)>>>perpendicularTo $ LinePV (Point2 (-1000) 268) (Vector2 (-50) 8)LinePV (Point2 (-1000) 268) (Vector2 8 50)
rightHalfPlane :: (Num r, Ord r) => LinePV 2 r -> HalfSpaceF (LinePV 2 r) Source #
Given the oriented line, computes the halfspace right of the line.
toLinearFunction :: (Fractional r, Ord r) => LinePV 2 r -> Maybe (LineEQ r) Source #
get values a,b s.t. the input line is described by y = ax + b. returns Nothing if the line is vertical
class HasDirection t where Source #
Types that have a Direction field
Methods
direction :: forall (d :: Nat) r. (Dimension t ~ d, NumType t ~ r) => Lens' t (Vector d r) Source #
Lens to access the direction field
Instances
| HasDirection (HalfLine point) Source # | |
| HasDirection (LinePV d r) Source # | |
class HasSupportingLine t where Source #
Types for which we can compute a supporting line, i.e. a line that contains the thing of type t.
Instances
| Point_ point d r => HasSupportingLine (HalfLine point) Source # | |
Defined in HGeometry.HalfLine | |
| HasSupportingLine t => HasSupportingLine (t :+ extra) Source # | |
Defined in HGeometry.Line.PointAndVector | |
| HasSupportingLine (LinePV d r) Source # | |
Defined in HGeometry.Line.PointAndVector | |
| (Point_ point d r, Has_ Metric_ d r, EndPoint_ (endPoint point), IxValue (endPoint point) ~ point, Num r) => HasSupportingLine (LineSegment endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal Methods supportingLine :: LineSegment endPoint point -> LinePV (Dimension (LineSegment endPoint point)) (NumType (LineSegment endPoint point)) Source # | |
data LinePV (d :: Nat) r Source #
A line is given by an anchor point and a vector indicating the direction.
Constructors
| LinePV | |
Fields
| |
Instances
class OnSideUpDownTest t where Source #
Class for types that support testing on which side (above, on, below) a particular point is.
Methods
onSideUpDown :: forall (d :: Nat) r point. (d ~ Dimension t, r ~ NumType t, Ord r, Num r, Point_ point d r) => point -> t -> SideTestUpDown Source #
Given a point q and a hyperplane h, compute to which side of h q lies. For vertical hyperplanes the left side of the hyperplane is interpeted as below.
Instances
| OnSideUpDownTest (LinePV 2 r) Source # | |
Result of a side test
Instances
| Read SideTest Source # | |
| Show SideTest Source # | |
| Eq SideTest Source # | |
| Ord SideTest Source # | |
Defined in HGeometry.Line.PointAndVector | |
data SideTestUpDown Source #
Result of a side test
Instances
| Read SideTestUpDown Source # | |
Defined in HGeometry.Line.PointAndVector | |
| Show SideTestUpDown Source # | |
Defined in HGeometry.Line.PointAndVector | |
| Eq SideTestUpDown Source # | |
Defined in HGeometry.Line.PointAndVector Methods (==) :: SideTestUpDown -> SideTestUpDown -> Bool Source # (/=) :: SideTestUpDown -> SideTestUpDown -> Bool Source # | |
| Ord SideTestUpDown Source # | |
Defined in HGeometry.Line.PointAndVector Methods compare :: SideTestUpDown -> SideTestUpDown -> Ordering Source # (<) :: SideTestUpDown -> SideTestUpDown -> Bool Source # (<=) :: SideTestUpDown -> SideTestUpDown -> Bool Source # (>) :: SideTestUpDown -> SideTestUpDown -> Bool Source # (>=) :: SideTestUpDown -> SideTestUpDown -> Bool Source # max :: SideTestUpDown -> SideTestUpDown -> SideTestUpDown Source # min :: SideTestUpDown -> SideTestUpDown -> SideTestUpDown Source # | |
module HGeometry.Line.General
type LineLineIntersection line = LineLineIntersectionG (NumType line) line Source #
data LineLineIntersectionG r line Source #
Line x Line intersections are either just points or lines.
Constructors
| Line_x_Line_Point (Point 2 r) | |
| Line_x_Line_Line line |
Instances
| Functor (LineLineIntersectionG r) Source # | |
Defined in HGeometry.Line.Intersection Methods fmap :: (a -> b) -> LineLineIntersectionG r a -> LineLineIntersectionG r b Source # (<$) :: a -> LineLineIntersectionG r b -> LineLineIntersectionG r a Source # | |
| (Read r, Read line) => Read (LineLineIntersectionG r line) Source # | |
Defined in HGeometry.Line.Intersection Methods readsPrec :: Int -> ReadS (LineLineIntersectionG r line) Source # readList :: ReadS [LineLineIntersectionG r line] Source # readPrec :: ReadPrec (LineLineIntersectionG r line) Source # readListPrec :: ReadPrec [LineLineIntersectionG r line] Source # | |
| (Show r, Show line) => Show (LineLineIntersectionG r line) Source # | |
Defined in HGeometry.Line.Intersection | |
| (Eq r, Eq line) => Eq (LineLineIntersectionG r line) Source # | |
Defined in HGeometry.Line.Intersection Methods (==) :: LineLineIntersectionG r line -> LineLineIntersectionG r line -> Bool Source # (/=) :: LineLineIntersectionG r line -> LineLineIntersectionG r line -> Bool Source # | |
Orphan instances
| Fractional r => HasSquaredEuclideanDistance (LineEQ r) Source # | |
Methods squaredEuclideanDistTo :: forall r0 (d :: Nat) point. (r0 ~ NumType (LineEQ r), d ~ Dimension (LineEQ r), Num r0, Point_ point d r0) => point -> LineEQ r -> r0 Source # pointClosestTo :: forall r0 (d :: Nat) point. (r0 ~ NumType (LineEQ r), d ~ Dimension (LineEQ r), Num r0, Point_ point d r0) => point -> LineEQ r -> Point d r0 Source # pointClosestToWithDistance :: forall r0 (d :: Nat) point. (r0 ~ NumType (LineEQ r), d ~ Dimension (LineEQ r), Num r0, Point_ point d r0) => point -> LineEQ r -> (Point d r0, r0) Source # | |
| (Eq r, Num r) => HasIntersectionWith (LineEQ r) (LinePV 2 r) Source # | |
| (Ord r, Fractional r) => IsIntersectableWith (LineEQ r) (LinePV 2 r) Source # | |