Maintainer  diagramsdiscuss@googlegroups.com 

Safe Haskell  None 
A segment is a translationinvariant, atomic path. Currently, there are two types: linear (i.e. just a straight line to the endpoint) and cubic Bézier curves (i.e. a curve to an endpoint with two control points). This module contains tools for creating and manipulating segments, as well as a definition of segments with a fixed location (useful for backend implementors).
Generally speaking, casual users of diagrams should not need this module; the higherlevel functionality provided by Diagrams.Trail, Diagrams.TrailLike, and Diagrams.Path should usually suffice. However, directly manipulating segments can occasionally be useful.
 data Open
 data Closed
 data Offset c v where
 OffsetOpen :: Offset Open v
 OffsetClosed :: !v > Offset Closed v
 segOffset :: Segment Closed v > v
 data Segment c v
 straight :: v > Segment Closed v
 bezier3 :: v > v > v > Segment Closed v
 bézier3 :: v > v > v > Segment Closed v
 reverseSegment :: AdditiveGroup v => Segment Closed v > Segment Closed v
 data FixedSegment v
 mkFixedSeg :: AdditiveGroup v => Located (Segment Closed v) > FixedSegment v
 fromFixedSeg :: AdditiveGroup v => FixedSegment v > Located (Segment Closed v)
 newtype SegCount = SegCount (Sum Int)
 newtype ArcLength v = ArcLength (Sum (Interval (Scalar v)), Scalar v > Sum (Interval (Scalar v)))
 getArcLengthCached :: ArcLength v > Interval (Scalar v)
 getArcLengthFun :: ArcLength v > Scalar v > Interval (Scalar v)
 getArcLengthBounded :: (Num (Scalar v), Ord (Scalar v)) => Scalar v > ArcLength v > Interval (Scalar v)
 newtype TotalOffset v = TotalOffset v
 data OffsetEnvelope v = OffsetEnvelope {
 _oeOffset :: !(TotalOffset v)
 _oeEnvelope :: Envelope v
 oeOffset :: forall v. Lens' (OffsetEnvelope v) (TotalOffset v)
 oeEnvelope :: forall v. Lens' (OffsetEnvelope v) (Envelope v)
 type SegMeasure v = SegCount ::: (ArcLength v ::: (OffsetEnvelope v ::: ()))
Open/closed tags
Type tag for closed segments.
(VectorSpace v, Num (Scalar v)) => EndValues (Tangent (Segment Closed v))  
(VectorSpace v, Num (Scalar v)) => Parametric (Tangent (Segment Closed v))  
(OrderedField (Scalar v), InnerSpace v) => Measured (SegMeasure v) (Segment Closed v)  
(InnerSpace v, OrderedField (Scalar v)) => Enveloped (Segment Closed v)  The envelope for a segment is based at the segment's start. 
Traced (Segment Closed R2)  
(InnerSpace v, Floating (Scalar v), Ord (Scalar v), AdditiveGroup v) => HasArcLength (Segment Closed v)  
(VectorSpace v, Fractional (Scalar v)) => Sectionable (Segment Closed v)  
(VectorSpace v, Num (Scalar v)) => EndValues (Segment Closed v)  
Num (Scalar v) => DomainBounds (Segment Closed v)  
(VectorSpace v, Num (Scalar v)) => Parametric (Segment Closed v) 

Segment offsets
The offset of a segment is the vector from its starting point to its end. The offset for an open segment is determined by the context, i.e. its endpoint is not fixed. The offset for a closed segment is stored explicitly, i.e. its endpoint is at a fixed offset from its start.
OffsetOpen :: Offset Open v  
OffsetClosed :: !v > Offset Closed v 
segOffset :: Segment Closed v > vSource
Compute the offset from the start of a segment to the
end. Note that in the case of a Bézier segment this is not the
same as the length of the curve itself; for that, see arcLength
.
Constructing and modifying segments
The atomic constituents of the concrete representation currently used for trails are segments, currently limited to single straight lines or cubic Bézier curves. Segments are translationally invariant, that is, they have no particular "location" and are unaffected by translations. They are, however, affected by other transformations such as rotations and scales.
Linear !(Offset c v)  A linear segment with given offset. 
Cubic !v !v !(Offset c v)  A cubic Bézier segment specified by three offsets from the starting point to the first control point, second control point, and ending point, respectively. 
straight :: v > Segment Closed vSource
constructs a translationally invariant linear
segment with direction and length given by the vector straight
vv
.
bezier3 :: v > v > v > Segment Closed vSource
bezier3 c1 c2 x
constructs a translationally invariant cubic
Bézier curve where the offsets from the first endpoint to the
first and second control point and endpoint are respectively
given by c1
, c2
, and x
.
bézier3 :: v > v > v > Segment Closed vSource
bézier3
is the same as bezier3
, but with more snobbery.
reverseSegment :: AdditiveGroup v => Segment Closed v > Segment Closed vSource
Reverse the direction of a segment.
Fixed (absolutely located) segments
data FixedSegment v Source
FixedSegment
s are like Segment
s except that they have
absolute locations. FixedSegment v
is isomorphic to Located
(Segment Closed v)
, as witnessed by mkFixedSeg
and
fromFixedSeg
, but FixedSegment
is convenient when one needs
the absolute locations of the vertices and control points.
Show v => Show (FixedSegment v)  
(InnerSpace v, OrderedField (Scalar v)) => Enveloped (FixedSegment v)  
Traced (FixedSegment R2)  
HasLinearMap v => Transformable (FixedSegment v)  
VectorSpace v => HasOrigin (FixedSegment v)  
(VectorSpace v, Fractional (Scalar v)) => Sectionable (FixedSegment v)  
(VectorSpace v, Num (Scalar v)) => EndValues (FixedSegment v)  
Num (Scalar v) => DomainBounds (FixedSegment v)  
VectorSpace v => Parametric (FixedSegment v) 
mkFixedSeg :: AdditiveGroup v => Located (Segment Closed v) > FixedSegment vSource
Create a FixedSegment
from a located Segment
.
fromFixedSeg :: AdditiveGroup v => FixedSegment v > Located (Segment Closed v)Source
Convert a FixedSegment
back into a located Segment
.
Segment measures
Trails store a sequence of segments in a fingertree, which can automatically track various monoidal "measures" on segments.
A type to track the count of segments in a Trail
.
Semigroup SegCount  
Monoid SegCount  
Wrapped SegCount  
Rewrapped SegCount SegCount  
(InnerSpace v, OrderedField (Scalar v)) => Measured (SegMeasure v) (SegMeasure v)  
(OrderedField (Scalar v), InnerSpace v) => Measured (SegMeasure v) (SegTree v)  
(OrderedField (Scalar v), InnerSpace v) => Measured (SegMeasure v) (Segment Closed v) 
A type to represent the total arc length of a chain of
segments. The first component is a "standard" arc length,
computed to within a tolerance of 10e6
. The second component is
a generic arc length function taking the tolerance as an
argument.
(Num (Scalar v), Ord (Scalar v)) => Semigroup (ArcLength v)  
(Num (Scalar v), Ord (Scalar v)) => Monoid (ArcLength v)  
Wrapped (ArcLength v)  
(InnerSpace v, OrderedField (Scalar v)) => Measured (SegMeasure v) (SegMeasure v)  
(OrderedField (Scalar v), InnerSpace v) => Measured (SegMeasure v) (SegTree v)  
Rewrapped (ArcLength v) (ArcLength v')  
(OrderedField (Scalar v), InnerSpace v) => Measured (SegMeasure v) (Segment Closed v) 
getArcLengthCached :: ArcLength v > Interval (Scalar v)Source
Project out the cached arc length, stored together with error bounds.
getArcLengthFun :: ArcLength v > Scalar v > Interval (Scalar v)Source
Project out the generic arc length function taking the tolerance as an argument.
getArcLengthBounded :: (Num (Scalar v), Ord (Scalar v)) => Scalar v > ArcLength v > Interval (Scalar v)Source
Given a specified tolerance, project out the cached arc length if it is accurate enough; otherwise call the generic arc length function with the given tolerance.
newtype TotalOffset v Source
A type to represent the total cumulative offset of a chain of segments.
AdditiveGroup v => Semigroup (TotalOffset v)  
AdditiveGroup v => Monoid (TotalOffset v)  
Wrapped (TotalOffset v)  
Rewrapped (TotalOffset v) (TotalOffset v') 
data OffsetEnvelope v Source
A type to represent the offset and envelope of a chain of segments. They have to be paired into one data structure, since combining the envelopes of two consecutive chains needs to take the offset of the the offset of the first into account.
OffsetEnvelope  

(InnerSpace v, OrderedField (Scalar v)) => Semigroup (OffsetEnvelope v)  
(InnerSpace v, OrderedField (Scalar v)) => Measured (SegMeasure v) (SegMeasure v)  
(OrderedField (Scalar v), InnerSpace v) => Measured (SegMeasure v) (SegTree v)  
(OrderedField (Scalar v), InnerSpace v) => Measured (SegMeasure v) (Segment Closed v) 
oeOffset :: forall v. Lens' (OffsetEnvelope v) (TotalOffset v)Source
oeEnvelope :: forall v. Lens' (OffsetEnvelope v) (Envelope v)Source
type SegMeasure v = SegCount ::: (ArcLength v ::: (OffsetEnvelope v ::: ()))Source
SegMeasure
collects up all the measurements over a chain of
segments.