Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Paths in 2D space.
This module exposes functions with the same names as Waterfall.Path, and if used together they should be imported qualified.
Synopsis
- data Path2D
- data Sense
- line :: V2 Double -> V2 Double -> Path2D
- lineTo :: V2 Double -> V2 Double -> (V2 Double, Path2D)
- lineRelative :: V2 Double -> V2 Double -> (V2 Double, Path2D)
- arc :: Sense -> Double -> V2 Double -> V2 Double -> Path2D
- arcTo :: Sense -> Double -> V2 Double -> V2 Double -> (V2 Double, Path2D)
- arcRelative :: Sense -> Double -> V2 Double -> V2 Double -> (V2 Double, Path2D)
- arcVia :: V2 Double -> V2 Double -> V2 Double -> Path2D
- arcViaTo :: V2 Double -> V2 Double -> V2 Double -> (V2 Double, Path2D)
- arcViaRelative :: V2 Double -> V2 Double -> V2 Double -> (V2 Double, Path2D)
- bezier :: V2 Double -> V2 Double -> V2 Double -> V2 Double -> Path2D
- bezierTo :: V2 Double -> V2 Double -> V2 Double -> V2 Double -> (V2 Double, Path2D)
- bezierRelative :: V2 Double -> V2 Double -> V2 Double -> V2 Double -> (V2 Double, Path2D)
- pathFrom :: V2 Double -> [V2 Double -> (V2 Double, Path2D)] -> Path2D
- pathFromTo :: [V2 Double -> (V2 Double, Path2D)] -> V2 Double -> (V2 Double, Path2D)
- repeatLooping :: Path2D -> Path2D
- closeLoop :: Path2D -> Path2D
Documentation
A Path in 2D Space
Under the hood, this is represented by an OpenCascade Wire
, constrained to the plane \(z=0\).
Please feel free to report a bug if you're able to construct a Path2D
which does not lie on this plane (without using Internal functions).
Instances
arc :: Sense -> Double -> V2 Double -> V2 Double -> Path2D Source #
Section of a circle, with a given radius, that lies between two points.
This may fail, if the radius is less than half of the distance between the points.
In general, arcVia
is the "safer" way to construct an arc
arcVia :: V2 Double -> V2 Double -> V2 Double -> Path2D Source #
Section of a circle based on three arguments, the start point, a point on the arc, and the endpoint
bezier :: V2 Double -> V2 Double -> V2 Double -> V2 Double -> Path2D Source #
Bezier curve of order 3
The arguments are, the start of the curve, the two control points, and the end of the curve
pathFrom :: V2 Double -> [V2 Double -> (V2 Double, Path2D)] -> Path2D Source #
When combining paths, we're generally interested in pairs of paths that share a common endpoint.
Rather than having to repeat these common endpoints, pathFrom
can be used to combine a list of path components.
Where a path component is a function from a start point, to a tuple of an end point, and a path; V2 Double -> (V2 Double, Path2D)
.
A typical use of pathFrom
uses a list of functions with the suffix "To" or "Relative", e.g.
Path2D.pathFrom (V2 (-1) (-1)) [ Path2D.arcViaTo (V2 (-1.5) 0) (V2 (-1) 1) , Path2D.lineTo (V2 1 1) , Path2D.bezierTo (V2 1.5 1) (V2 1.5 (-1)) (V2 1 (-1)) , Path2D.lineTo (V2 (-1) (-1)) ]
pathFromTo :: [V2 Double -> (V2 Double, Path2D)] -> V2 Double -> (V2 Double, Path2D) Source #
Combines a list of "path components", as used by pathFrom
repeatLooping :: Path2D -> Path2D Source #
Given a Path where both endpoints are equidistant from the origin.
And which subtends an angle \( φ \) from the origin that evenly divides a complete revolution, such that \(n φ = 2 π \).
Replicates the path \( n \) times, rotating it by \( φ \), until the resulting path completes one revolution around the origin.
This can be used to construct paths with rotational symmetry, such as regular polygons, or gears.