waterfall-cad-0.2.2.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

fromWire, pointToGPPnt

Instances

Instances details
AnyPath (V2 Double) Path2D Source # 
Instance details

Defined in Waterfall.Path.Common

Methods

fromWire :: Acquire (Ptr Wire) -> Path2D

pointToGPPnt :: Proxy Path2D -> V2 Double -> Acquire (Ptr Pnt)

AnyPath (V3 Double) Path Source # 
Instance details

Defined in Waterfall.Path.Common

Methods

fromWire :: Acquire (Ptr Wire) -> Path

pointToGPPnt :: Proxy Path -> V3 Double -> Acquire (Ptr Pnt)

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

A straight line between two points

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

Version of line designed to work with pathFrom

lineRelative :: (AnyPath point path, Num 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 => 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 => 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, Num 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 => 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 => point -> point -> point -> point -> (point, path) Source #

Version of bezier designed to work with pathFrom

bezierRelative :: (AnyPath point path, Num 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