Generic functionality for constructing and manipulating linear or cubic Bezier segments.
- data Segment v
- straight :: v -> Segment v
- bezier3 :: v -> v -> v -> Segment v
- atParam :: (VectorSpace v, Num (Scalar v)) => Segment v -> Scalar v -> v
- segOffset :: Segment v -> v
- splitAtParam :: VectorSpace v => Segment v -> Scalar v -> (Segment v, Segment v)
- arcLength :: (InnerSpace v, Floating (Scalar v), Ord (Scalar v)) => Segment v -> Scalar v -> Scalar v
The atomic constituents of paths are segments, which are single straight lines or cubic Bezier 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.
A linear segment with given offset.
|Cubic v v v|
A cubic bezier segment specified by three offsets from the starting point to the first control point, second control point, and ending point, respectively.
|Eq v => Eq (Segment v)|
|Ord v => Ord (Segment v)|
|Show v => Show (Segment v)|
|(InnerSpace v, OrderedField (Scalar v)) => Boundable (Segment v)|
The bounding function for a segment is based at the segment's start.
|HasLinearMap v => Transformable (Segment v)|
|(Show v, HasLinearMap v) => Renderable (Segment v) ShowBackend|
constructs a translationally invariant linear
segment with direction and length given by the vector
bezier3 v1 v2 v3 constructs a translationally invariant cubic
Bezier curve where the offsets from the first endpoint to the
first and second control point and endpoint are respectively
Computing with segments
Compute the offset from the start of a segment to the
end. Note that in the case of a Bezier segment this is not the
same as the length of the curve itself; for that, see
splitAtParam splits a segment
s into two new segments
at the parameter
l corresponds to the portion of
s for parameter values from
The following should hold for splitting:
paramSplit s t u | u < t = atParam s u == atParam l (u / t) | otherwise = atParam s u == atParam s t ^+^ atParam l ((u - t) / (1.0 - t)) where (l,r) = splitAtParam s t
That is to say, the parameterization scales linearly with splitting.