waterfall-cad-0.5.1.0: Declarative CAD/Solid Modeling Library
Safe HaskellNone
LanguageHaskell2010

Waterfall.Path.Common

Description

Paths in 2D / 3D space.

This module defines functions that can be used with Waterfall.Path or Waterfall.TwoD.Path2D. Those modules both export monomorphized variants of the functions defined in this module

Synopsis

Documentation

class AnyPath point path | path -> point Source #

Class used to abstract over constructing Path and Path2D

There are instances for AnyPath (V3 Double) Path and for AnyPath (V2 Double) Path2D

Minimal complete definition

reconstructPath, deconstructPath, pointToV3, v3ToPoint

line :: (AnyPath point path, Epsilon point) => point -> point -> path Source #

A straight line between two points

lineTo :: (AnyPath point path, Epsilon point) => point -> point -> (point, path) Source #

Version of line designed to work with pathFrom

lineRelative :: (AnyPath point path, Epsilon point) => point -> point -> (point, path) Source #

Version of line designed to work with pathFrom

With relative points; specifying the distance of the endpoint relative to the start of the line, rather than in absolute space.

arcVia :: (AnyPath point path, Epsilon point) => point -> point -> point -> path Source #

Section of a circle based on three arguments, the start point, a point on the arc, and the endpoint

arcViaTo :: (AnyPath point path, Epsilon point) => point -> point -> point -> (point, path) Source #

Version of arcVia designed to work with pathFrom

The first argument is a point on the arc The second argument is the endpoint of the arc

arcViaRelative :: (AnyPath point path, Epsilon point) => point -> point -> point -> (point, path) Source #

Version of arcVia designed to work with pathFrom

With relative points; specifying the distance of the midpoint and endpoint relative to the start of the line, rather than in absolute space.

bezier :: (AnyPath point path, Epsilon point) => point -> point -> point -> point -> path Source #

Bezier curve of order 3

The arguments are, the start of the curve, the two control points, and the end of the curve

bezierTo :: (AnyPath point path, Epsilon point) => point -> point -> point -> point -> (point, path) Source #

Version of bezier designed to work with pathFrom

bezierRelative :: (AnyPath point path, Epsilon point) => point -> point -> point -> point -> (point, path) Source #

Version of bezier designed to work with pathFrom

With relative points; specifying the distance of the control points and the endpoint relative to the start of the line, rather than in absolute space.

pathFrom :: Monoid path => point -> [point -> (point, path)] -> path 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:

 Path.pathFrom zero 
    [ Path.bezierRelative (V3 0 0 0.5) (V3 0.5 0.5 0.5) (V3 0.5 0.5 1)
    , Path.bezierRelative (V3 0 0 0.5) (V3 (-0.5) (-0.5) 0.5) (V3 (-0.5) (-0.5) 1)
    , Path.arcViaRelative (V3 0 1 1) (V3 0 2 0)
    , Path.lineTo (V3 0 2 0) 
    ]

pathFromTo :: Monoid path => [point -> (point, path)] -> point -> (point, path) Source #

Combines a list of "path components", as used by pathFrom

pathEndpoints :: AnyPath point path => path -> Maybe (point, point) Source #

Returns the start and end of a Path

splice :: (AnyPath point path, Num point) => path -> point -> (point, path) Source #

Convert a path into a function that can be used as an argument to pathFrom

Takes a path, and returns a function which takes a new start point for the path, and returns tupled, the path translated onto the new start point, and the new endpoint

closeLoop :: (AnyPath point path, Monoid path, Epsilon point) => path -> path Source #

Given a path, return a new path with the endpoints joined by a straight line.

reversePath :: AnyPath point path => path -> path Source #

splitPath :: AnyPath point path => path -> [path] Source #

Break a path appart at any "non smooth" point