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

HGeometry.LineSegment.Class

Description

A class representing line segments

Synopsis

Documentation

class (IntervalLike_ lineSegment point, Point_ point (Dimension lineSegment) (NumType lineSegment)) => LineSegment_ lineSegment point | lineSegment -> point Source #

A class representing line segments

Instances

Instances details
LineSegment_ lineSegment point => LineSegment_ (ByIndex ix lineSegment) point Source # 
Instance details

Defined in HGeometry.LineSegment.Class

LineSegment_ segment point => LineSegment_ (segment :+ extra) point Source # 
Instance details

Defined in HGeometry.LineSegment.Class

(IxValue (endPoint point) ~ point, EndPoint_ (endPoint point), Point_ point (Dimension point) (NumType point)) => LineSegment_ (LineSegment endPoint point) point Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

pattern LineSegment_ :: LineSegment_ lineSegment point => point -> point -> lineSegment Source #

Deconstructs a line segment from the start and end point

class LineSegment_ lineSegment point => ConstructableLineSegment_ lineSegment point where Source #

A class representing line segments

Minimal complete definition

uncheckedLineSegment

Methods

uncheckedLineSegment :: point -> point -> lineSegment Source #

Create a segment

pre: the points are disjoint

mkLineSegment :: point -> point -> Maybe lineSegment Source #

smart constructor that creates a valid segment, i.e. it validates that the endpoints are disjoint.

Instances

Instances details
(ConstructableLineSegment_ segment point, Default extra) => ConstructableLineSegment_ (segment :+ extra) point Source # 
Instance details

Defined in HGeometry.LineSegment.Class

Methods

uncheckedLineSegment :: point -> point -> segment :+ extra Source #

mkLineSegment :: point -> point -> Maybe (segment :+ extra) Source #

(IxValue (endPoint point) ~ point, EndPoint_ (endPoint point), Point_ point (Dimension point) (NumType point)) => ConstructableLineSegment_ (LineSegment endPoint point) point Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

uncheckedLineSegment :: point -> point -> LineSegment endPoint point Source #

mkLineSegment :: point -> point -> Maybe (LineSegment endPoint point) Source #

class (LineSegment_ lineSegment point, StartPointOf lineSegment ~ EndPoint 'Closed point, EndPointOf lineSegment ~ EndPoint 'Closed point) => ClosedLineSegment_ lineSegment point Source #

A class representing Closed Linesegments

Instances

Instances details
Point_ point (Dimension point) (NumType point) => ClosedLineSegment_ (ClosedLineSegment point) point Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

ClosedLineSegment_ segment point => ClosedLineSegment_ (segment :+ extra) point Source # 
Instance details

Defined in HGeometry.LineSegment.Class

class (LineSegment_ lineSegment point, StartPointOf lineSegment ~ EndPoint 'Open point, EndPointOf lineSegment ~ EndPoint 'Open point) => OpenLineSegment_ lineSegment point Source #

A Class representing Open ended linesegments

Instances

Instances details
Point_ point (Dimension point) (NumType point) => OpenLineSegment_ (OpenLineSegment point) point Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

OpenLineSegment_ segment point => OpenLineSegment_ (segment :+ extra) point Source # 
Instance details

Defined in HGeometry.LineSegment.Class

interpolate :: forall lineSegment (d :: Nat) point r. (Fractional r, LineSegment_ lineSegment point, ConstructablePoint_ point d r) => r -> lineSegment -> point Source #

Linearly interpolate the two endpoints with a value in the range [0,1]

>>> interpolate 0.5 $ ClosedLineSegment origin (Point2 10.0 10.0)
Point2 5.0 5.0
>>> interpolate 0.1 $ ClosedLineSegment origin (Point2 10.0 10.0)
Point2 1.0 1.0
>>> interpolate 0 $ ClosedLineSegment origin (Point2 10.0 10.0)
Point2 0.0 0.0
>>> interpolate 1 $ ClosedLineSegment origin (Point2 10.0 10.0)
Point2 10.0 10.0

class HasOnSegment lineSegment (d :: Nat) | lineSegment -> d where Source #

Class that expresses that we can test if the segment contains a point

Methods

onSegment :: (Ord r, Point_ point d r, r ~ NumType lineSegment, d ~ Dimension lineSegment) => point -> lineSegment -> Bool Source #

Test if a point lies on a line segment.

As a user, you should typically just use intersects instead.

Instances

Instances details
(Point_ point d r, Fractional r) => HasOnSegment (ClosedLineSegment point) d Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

onSegment :: (Ord r0, Point_ point0 d r0, r0 ~ NumType (ClosedLineSegment point), d ~ Dimension (ClosedLineSegment point)) => point0 -> ClosedLineSegment point -> Bool Source #

(Point_ point 2 r, Num r) => HasOnSegment (ClosedLineSegment point) 2 Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

onSegment :: (Ord r0, Point_ point0 2 r0, r0 ~ NumType (ClosedLineSegment point), 2 ~ Dimension (ClosedLineSegment point)) => point0 -> ClosedLineSegment point -> Bool Source #

(Point_ point d r, Fractional r) => HasOnSegment (OpenLineSegment point) d Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

onSegment :: (Ord r0, Point_ point0 d r0, r0 ~ NumType (OpenLineSegment point), d ~ Dimension (OpenLineSegment point)) => point0 -> OpenLineSegment point -> Bool Source #

(Point_ point 2 r, Num r) => HasOnSegment (OpenLineSegment point) 2 Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

onSegment :: (Ord r0, Point_ point0 2 r0, r0 ~ NumType (OpenLineSegment point), 2 ~ Dimension (OpenLineSegment point)) => point0 -> OpenLineSegment point -> Bool Source #

HasOnSegment lineSegment d => HasOnSegment (ByIndex ix lineSegment) d Source # 
Instance details

Defined in HGeometry.LineSegment.Class

Methods

onSegment :: (Ord r, Point_ point d r, r ~ NumType (ByIndex ix lineSegment), d ~ Dimension (ByIndex ix lineSegment)) => point -> ByIndex ix lineSegment -> Bool Source #

HasOnSegment lineSegment d => HasOnSegment (lineSegment :+ extra) d Source # 
Instance details

Defined in HGeometry.LineSegment.Class

Methods

onSegment :: (Ord r, Point_ point d r, r ~ NumType (lineSegment :+ extra), d ~ Dimension (lineSegment :+ extra)) => point -> (lineSegment :+ extra) -> Bool Source #

(Point_ point d r, Fractional r) => HasOnSegment (LineSegment AnEndPoint point) d Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

onSegment :: (Ord r0, Point_ point0 d r0, r0 ~ NumType (LineSegment AnEndPoint point), d ~ Dimension (LineSegment AnEndPoint point)) => point0 -> LineSegment AnEndPoint point -> Bool Source #

(Point_ point 2 r, Num r) => HasOnSegment (LineSegment AnEndPoint point) 2 Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

onSegment :: (Ord r0, Point_ point0 2 r0, r0 ~ NumType (LineSegment AnEndPoint point), 2 ~ Dimension (LineSegment AnEndPoint point)) => point0 -> LineSegment AnEndPoint point -> Bool Source #

class HasStart seg p | seg -> p where Source #

Things that have a start point

Methods

start :: Lens' seg p Source #

Lens to access the start point

Instances

Instances details
HasStart (HalfLine point) point Source # 
Instance details

Defined in HGeometry.HalfLine

Methods

start :: Lens' (HalfLine point) point Source #

HasStart (HalfOpenInterval r) r Source # 
Instance details

Defined in HGeometry.Interval.HalfOpen

HasStart seg p => HasStart (ByIndex ix seg) p Source # 
Instance details

Defined in HGeometry.Interval.Class

Methods

start :: Lens' (ByIndex ix seg) p Source #

HasStart seg p => HasStart (seg :+ extra) p Source # 
Instance details

Defined in HGeometry.Interval.Class

Methods

start :: Lens' (seg :+ extra) p Source #

(IxValue (endPoint point) ~ point, EndPoint_ (endPoint point)) => HasStart (LineSegment endPoint point) point Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

start :: Lens' (LineSegment endPoint point) point Source #

(EndPoint_ (endPoint r), IxValue (endPoint r) ~ r) => HasStart (Interval endPoint r) r Source # 
Instance details

Defined in HGeometry.Interval.Internal

Methods

start :: Lens' (Interval endPoint r) r Source #

class HasEnd seg p | seg -> p where Source #

Things that have an end point

Methods

end :: Lens' seg p Source #

Lens to access the ending point

Instances

Instances details
HasEnd (HalfOpenInterval r) r Source # 
Instance details

Defined in HGeometry.Interval.HalfOpen

HasEnd seg p => HasEnd (ByIndex ix seg) p Source # 
Instance details

Defined in HGeometry.Interval.Class

Methods

end :: Lens' (ByIndex ix seg) p Source #

HasEnd seg p => HasEnd (seg :+ extra) p Source # 
Instance details

Defined in HGeometry.Interval.Class

Methods

end :: Lens' (seg :+ extra) p Source #

(IxValue (endPoint point) ~ point, EndPoint_ (endPoint point)) => HasEnd (LineSegment endPoint point) point Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

end :: Lens' (LineSegment endPoint point) point Source #

(EndPoint_ (endPoint r), IxValue (endPoint r) ~ r) => HasEnd (Interval endPoint r) r Source # 
Instance details

Defined in HGeometry.Interval.Internal

Methods

end :: Lens' (Interval endPoint r) r Source #

class HasStartPoint seg p | seg -> p where Source #

Things that have a start point

Methods

startPoint :: Lens' seg p Source #

Lens to access the start point

Instances

Instances details
HasStartPoint (HalfOpenInterval r) (EndPoint 'Open r) Source # 
Instance details

Defined in HGeometry.Interval.HalfOpen

HasStartPoint seg p => HasStartPoint (ByIndex ix seg) p Source # 
Instance details

Defined in HGeometry.Interval.Class

Methods

startPoint :: Lens' (ByIndex ix seg) p Source #

HasStartPoint seg p => HasStartPoint (seg :+ extra) p Source # 
Instance details

Defined in HGeometry.Interval.Class

Methods

startPoint :: Lens' (seg :+ extra) p Source #

IxValue (endPoint point) ~ point => HasStartPoint (LineSegment endPoint point) (endPoint point) Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

startPoint :: Lens' (LineSegment endPoint point) (endPoint point) Source #

HasStartPoint (Interval endPoint r) (endPoint r) Source # 
Instance details

Defined in HGeometry.Interval.Internal

Methods

startPoint :: Lens' (Interval endPoint r) (endPoint r) Source #

class HasEndPoint seg p | seg -> p where Source #

Things that have an end point

Methods

endPoint :: Lens' seg p Source #

Lens to access the ending point

Instances

Instances details
HasEndPoint (HalfOpenInterval r) (EndPoint 'Closed r) Source # 
Instance details

Defined in HGeometry.Interval.HalfOpen

HasEndPoint seg p => HasEndPoint (ByIndex ix seg) p Source # 
Instance details

Defined in HGeometry.Interval.Class

Methods

endPoint :: Lens' (ByIndex ix seg) p Source #

HasEndPoint seg p => HasEndPoint (seg :+ extra) p Source # 
Instance details

Defined in HGeometry.Interval.Class

Methods

endPoint :: Lens' (seg :+ extra) p Source #

IxValue (endPoint point) ~ point => HasEndPoint (LineSegment endPoint point) (endPoint point) Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

Methods

endPoint :: Lens' (LineSegment endPoint point) (endPoint point) Source #

HasEndPoint (Interval endPoint r) (endPoint r) Source # 
Instance details

Defined in HGeometry.Interval.Internal

Methods

endPoint :: Lens' (Interval endPoint r) (endPoint r) Source #

type family StartPointOf interval Source #

type family to declare the type of startpoint for an interval, the idea is to define this as one of the endpoinst form the Endpoints module

Instances

Instances details
type StartPointOf (HalfOpenInterval r) Source # 
Instance details

Defined in HGeometry.Interval.HalfOpen

type StartPointOf (ByIndex ix interval) Source # 
Instance details

Defined in HGeometry.Interval.Class

type StartPointOf (ByIndex ix interval) = StartPointOf interval
type StartPointOf (interval :+ extra) Source # 
Instance details

Defined in HGeometry.Interval.Class

type StartPointOf (interval :+ extra) = StartPointOf interval
type StartPointOf (LineSegment endPoint point) Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

type StartPointOf (LineSegment endPoint point) = endPoint point
type StartPointOf (Interval endPoint r) Source # 
Instance details

Defined in HGeometry.Interval.Internal

type StartPointOf (Interval endPoint r) = endPoint r

type family EndPointOf interval Source #

type family to declare the type of endpoint for an interval, the idea is to define this as one of the endpoinst form the Endpoints module

Instances

Instances details
type EndPointOf (HalfOpenInterval r) Source # 
Instance details

Defined in HGeometry.Interval.HalfOpen

type EndPointOf (ByIndex ix interval) Source # 
Instance details

Defined in HGeometry.Interval.Class

type EndPointOf (ByIndex ix interval) = EndPointOf interval
type EndPointOf (interval :+ extra) Source # 
Instance details

Defined in HGeometry.Interval.Class

type EndPointOf (interval :+ extra) = EndPointOf interval
type EndPointOf (LineSegment endPoint point) Source # 
Instance details

Defined in HGeometry.LineSegment.Internal

type EndPointOf (LineSegment endPoint point) = endPoint point
type EndPointOf (Interval endPoint r) Source # 
Instance details

Defined in HGeometry.Interval.Internal

type EndPointOf (Interval endPoint r) = endPoint r

ordAtY :: (Num r, Ord r, LineSegment_ lineSegment point, Point_ point 2 r) => r -> lineSegment -> lineSegment -> Ordering Source #

Given a y-coordinate, compare the segments based on the x-coordinate of the intersection with the horizontal line through y

ordAtX :: (Num r, Ord r, LineSegment_ lineSegment point, Point_ point 2 r) => r -> lineSegment -> lineSegment -> Ordering Source #

Given an x-coordinate, compare the segments based on the y-coordinate of the intersection with the horizontal line through y

xCoordAt :: (Fractional r, Ord r, LineSegment_ lineSegment point, Point_ point 2 r) => r -> lineSegment -> r Source #

Given a y coord and a line segment that intersects the horizontal line through y, compute the x-coordinate of this intersection point.

note that we will pretend that the line segment is closed, even if it is not

yCoordAt :: (Fractional r, Ord r, LineSegment_ lineSegment point, Point_ point 2 r) => r -> lineSegment -> r Source #

Given an x-coordinate and a line segment that intersects the vertical line through x, compute the y-coordinate of this intersection point.

note that we will pretend that the line segment is closed, even if it is not

orientLR :: forall lineSegment point (d :: Nat) r. (LineSegment_ lineSegment point, Point_ point d r, 1 <= d, Ord r) => lineSegment -> lineSegment Source #

Orient the segment from left to right

orientBT :: forall lineSegment point (d :: Nat) r. (LineSegment_ lineSegment point, Point_ point d r, 2 <= d, Ord r) => lineSegment -> lineSegment Source #

Orient the segment from bottom to top