| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.LineSegment.Class
Description
A class representing line segments
Synopsis
- class (IntervalLike_ lineSegment point, Point_ point (Dimension lineSegment) (NumType lineSegment)) => LineSegment_ lineSegment point | lineSegment -> point
- pattern LineSegment_ :: LineSegment_ lineSegment point => point -> point -> lineSegment
- class LineSegment_ lineSegment point => ConstructableLineSegment_ lineSegment point where
- uncheckedLineSegment :: point -> point -> lineSegment
- mkLineSegment :: point -> point -> Maybe lineSegment
- class (LineSegment_ lineSegment point, StartPointOf lineSegment ~ EndPoint 'Closed point, EndPointOf lineSegment ~ EndPoint 'Closed point) => ClosedLineSegment_ lineSegment point
- class (LineSegment_ lineSegment point, StartPointOf lineSegment ~ EndPoint 'Open point, EndPointOf lineSegment ~ EndPoint 'Open point) => OpenLineSegment_ lineSegment point
- interpolate :: forall lineSegment (d :: Nat) point r. (Fractional r, LineSegment_ lineSegment point, ConstructablePoint_ point d r) => r -> lineSegment -> point
- class HasOnSegment lineSegment (d :: Nat) | lineSegment -> d where
- class HasStart seg p | seg -> p where
- class HasEnd seg p | seg -> p where
- class HasStartPoint seg p | seg -> p where
- startPoint :: Lens' seg p
- class HasEndPoint seg p | seg -> p where
- type family StartPointOf interval
- type family EndPointOf interval
- ordAtY :: (Num r, Ord r, LineSegment_ lineSegment point, Point_ point 2 r) => r -> lineSegment -> lineSegment -> Ordering
- ordAtX :: (Num r, Ord r, LineSegment_ lineSegment point, Point_ point 2 r) => r -> lineSegment -> lineSegment -> Ordering
- xCoordAt :: (Fractional r, Ord r, LineSegment_ lineSegment point, Point_ point 2 r) => r -> lineSegment -> r
- yCoordAt :: (Fractional r, Ord r, LineSegment_ lineSegment point, Point_ point 2 r) => r -> lineSegment -> r
- orientLR :: forall lineSegment point (d :: Nat) r. (LineSegment_ lineSegment point, Point_ point d r, 1 <= d, Ord r) => lineSegment -> lineSegment
- orientBT :: forall lineSegment point (d :: Nat) r. (LineSegment_ lineSegment point, Point_ point d r, 2 <= d, Ord r) => lineSegment -> lineSegment
Documentation
class (IntervalLike_ lineSegment point, Point_ point (Dimension lineSegment) (NumType lineSegment)) => LineSegment_ lineSegment point | lineSegment -> point Source #
A class representing line segments
Instances
| LineSegment_ lineSegment point => LineSegment_ (ByIndex ix lineSegment) point Source # | |
Defined in HGeometry.LineSegment.Class | |
| LineSegment_ segment point => LineSegment_ (segment :+ extra) point Source # | |
Defined in HGeometry.LineSegment.Class | |
| (IxValue (endPoint point) ~ point, EndPoint_ (endPoint point), Point_ point (Dimension point) (NumType point)) => LineSegment_ (LineSegment endPoint point) point Source # | |
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
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
| (ConstructableLineSegment_ segment point, Default extra) => ConstructableLineSegment_ (segment :+ extra) point Source # | |
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 # | |
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
| Point_ point (Dimension point) (NumType point) => ClosedLineSegment_ (ClosedLineSegment point) point Source # | |
Defined in HGeometry.LineSegment.Internal | |
| ClosedLineSegment_ segment point => ClosedLineSegment_ (segment :+ extra) point Source # | |
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
| Point_ point (Dimension point) (NumType point) => OpenLineSegment_ (OpenLineSegment point) point Source # | |
Defined in HGeometry.LineSegment.Internal | |
| OpenLineSegment_ segment point => OpenLineSegment_ (segment :+ extra) point Source # | |
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
class HasStart seg p | seg -> p where Source #
Things that have a start point
Instances
| HasStart (HalfLine point) point Source # | |
| HasStart (HalfOpenInterval r) r Source # | |
Defined in HGeometry.Interval.HalfOpen Methods start :: Lens' (HalfOpenInterval r) r Source # | |
| HasStart seg p => HasStart (ByIndex ix seg) p Source # | |
| HasStart seg p => HasStart (seg :+ extra) p Source # | |
| (IxValue (endPoint point) ~ point, EndPoint_ (endPoint point)) => HasStart (LineSegment endPoint point) point Source # | |
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 # | |
class HasEnd seg p | seg -> p where Source #
Things that have an end point
Instances
| HasEnd (HalfOpenInterval r) r Source # | |
Defined in HGeometry.Interval.HalfOpen Methods end :: Lens' (HalfOpenInterval r) r Source # | |
| HasEnd seg p => HasEnd (ByIndex ix seg) p Source # | |
| HasEnd seg p => HasEnd (seg :+ extra) p Source # | |
| (IxValue (endPoint point) ~ point, EndPoint_ (endPoint point)) => HasEnd (LineSegment endPoint point) point Source # | |
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 # | |
class HasStartPoint seg p | seg -> p where Source #
Things that have a start point
Instances
| HasStartPoint (HalfOpenInterval r) (EndPoint 'Open r) Source # | |
Defined in HGeometry.Interval.HalfOpen Methods startPoint :: Lens' (HalfOpenInterval r) (EndPoint 'Open r) Source # | |
| HasStartPoint seg p => HasStartPoint (ByIndex ix seg) p Source # | |
Defined in HGeometry.Interval.Class Methods startPoint :: Lens' (ByIndex ix seg) p Source # | |
| HasStartPoint seg p => HasStartPoint (seg :+ extra) p Source # | |
Defined in HGeometry.Interval.Class Methods startPoint :: Lens' (seg :+ extra) p Source # | |
| IxValue (endPoint point) ~ point => HasStartPoint (LineSegment endPoint point) (endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal Methods startPoint :: Lens' (LineSegment endPoint point) (endPoint point) Source # | |
| HasStartPoint (Interval endPoint r) (endPoint r) Source # | |
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
Instances
| HasEndPoint (HalfOpenInterval r) (EndPoint 'Closed r) Source # | |
Defined in HGeometry.Interval.HalfOpen | |
| HasEndPoint seg p => HasEndPoint (ByIndex ix seg) p Source # | |
| HasEndPoint seg p => HasEndPoint (seg :+ extra) p Source # | |
| IxValue (endPoint point) ~ point => HasEndPoint (LineSegment endPoint point) (endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal Methods endPoint :: Lens' (LineSegment endPoint point) (endPoint point) Source # | |
| HasEndPoint (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
| type StartPointOf (HalfOpenInterval r) Source # | |
Defined in HGeometry.Interval.HalfOpen | |
| type StartPointOf (ByIndex ix interval) Source # | |
Defined in HGeometry.Interval.Class | |
| type StartPointOf (interval :+ extra) Source # | |
Defined in HGeometry.Interval.Class | |
| type StartPointOf (LineSegment endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal | |
| type StartPointOf (Interval endPoint r) Source # | |
Defined in HGeometry.Interval.Internal | |
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
| type EndPointOf (HalfOpenInterval r) Source # | |
Defined in HGeometry.Interval.HalfOpen | |
| type EndPointOf (ByIndex ix interval) Source # | |
Defined in HGeometry.Interval.Class | |
| type EndPointOf (interval :+ extra) Source # | |
Defined in HGeometry.Interval.Class | |
| type EndPointOf (LineSegment endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal | |
| type EndPointOf (Interval endPoint r) Source # | |
Defined in HGeometry.Interval.Internal | |
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