| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Line.PointAndVector
Description
\(d\)-dimensional lines.
Synopsis
- data LinePV (d :: Nat) r = LinePV {
- _anchorPoint :: !(Point d r)
- _direction :: !(Vector d r)
- anchorPoint :: forall (d :: Nat) r f. Functor f => (Point d r -> f (Point d r)) -> LinePV d r -> f (LinePV d r)
- class HasDirection t where
- isIdenticalTo :: forall (d :: Nat) r. Eq (Vector d r) => LinePV d r -> LinePV d r -> Bool
- class HasSupportingLine t where
- supportingLine :: t -> LinePV (Dimension t) (NumType t)
- fromLinearFunction :: Num r => r -> r -> LinePV 2 r
- toLinearFunction :: (Fractional r, Ord r) => LinePV 2 r -> Maybe (LineEQ r)
- data SideTestUpDown
- 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
- liesAbove :: (Ord r, Num r, Point_ point 2 r) => point -> LinePV 2 r -> Bool
- liesBelow :: (Ord r, Num r, Point_ point 2 r) => point -> LinePV 2 r -> Bool
- data SideTest
- onSide :: (Ord r, Num r, Point_ point 2 r) => point -> LinePV 2 r -> SideTest
- leftHalfPlane :: (Num r, Ord r) => LinePV 2 r -> HalfSpaceF (LinePV 2 r)
- rightHalfPlane :: (Num r, Ord r) => LinePV 2 r -> HalfSpaceF (LinePV 2 r)
- bisector :: (Fractional r, Point_ point 2 r) => point -> point -> LinePV 2 r
- perpendicularTo :: Num r => LinePV 2 r -> LinePV 2 r
- isPerpendicularTo :: (Num r, Eq r) => Vector 2 r -> LinePV 2 r -> Bool
- cmpSlope :: (Num r, Ord r) => LinePV 2 r -> LinePV 2 r -> Ordering
Documentation
data LinePV (d :: Nat) r Source #
A line is given by an anchor point and a vector indicating the direction.
Constructors
| LinePV | |
Fields
| |
Instances
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
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 # | |
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.
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 # | |
fromLinearFunction :: Num r => r -> r -> LinePV 2 r Source #
Create a line from the linear function ax + b
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
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 # | |
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 # | |
liesAbove :: (Ord r, Num r, Point_ point 2 r) => point -> LinePV 2 r -> Bool Source #
Test if the query point q lies (strictly) above line l
liesBelow :: (Ord r, Num r, Point_ point 2 r) => point -> LinePV 2 r -> Bool Source #
Test if the query point q lies (strictly) above line l
Result of a side test
Instances
| Read SideTest Source # | |
| Show SideTest Source # | |
| Eq SideTest Source # | |
| Ord SideTest Source # | |
Defined in HGeometry.Line.PointAndVector | |
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
leftHalfPlane :: (Num r, Ord r) => LinePV 2 r -> HalfSpaceF (LinePV 2 r) Source #
Given the oriented line, computes the halfspace left of the line.
rightHalfPlane :: (Num r, Ord r) => LinePV 2 r -> HalfSpaceF (LinePV 2 r) Source #
Given the oriented line, computes the halfspace right of the line.
bisector :: (Fractional r, Point_ point 2 r) => point -> point -> LinePV 2 r Source #
Get the bisector between two points
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)
isPerpendicularTo :: (Num r, Eq r) => Vector 2 r -> LinePV 2 r -> Bool Source #
Test if a vector is perpendicular to the line.
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