Maintainer | diagrams-discuss@googlegroups.com |
---|---|

Safe Haskell | None |

Two-dimensional arcs, approximated by cubic bezier curves.

- arc :: (Angle a, TrailLike t, V t ~ R2) => a -> a -> t
- arc' :: (Angle a, TrailLike p, V p ~ R2) => Double -> a -> a -> p
- arcCW :: (Angle a, TrailLike t, V t ~ R2) => a -> a -> t
- arcT :: Angle a => a -> a -> Trail R2
- bezierFromSweep :: Rad -> [Segment Closed R2]
- wedge :: (Angle a, TrailLike p, V p ~ R2) => Double -> a -> a -> p
- arcBetween :: (TrailLike t, V t ~ R2) => P2 -> P2 -> Double -> t
- annularWedge :: (Angle a, TrailLike p, V p ~ R2) => Double -> Double -> a -> a -> p

# Documentation

arc :: (Angle a, TrailLike t, V t ~ R2) => a -> a -> tSource

Given a start angle `s`

and an end angle `e`

,

is the
path of a radius one arc counterclockwise between the two angles.
The origin of the arc is its center.
`arc`

s e

arc' :: (Angle a, TrailLike p, V p ~ R2) => Double -> a -> a -> pSource

Given a radus `r`

, a start angle `s`

and an end angle `e`

,

is the path of a radius `arc'`

r s e`(abs r)`

arc between
the two angles. If a negative radius is given, the arc will
be clockwise, otherwise it will be counterclockwise. The origin
of the arc is its center.

arc'Ex = mconcat [ arc' r 0 (1/4 :: Turn) | r <- [0.5,-1,1.5] ] # centerXY # pad 1.1

bezierFromSweep :: Rad -> [Segment Closed R2]Source

`bezierFromSweep s`

constructs a series of `Cubic`

segments that
start in the positive y direction and sweep counter clockwise
through `s`

radians. If `s`

is negative, it will start in the
negative y direction and sweep clockwise. When `s`

is less than
0.0001 the empty list results. If the sweep is greater than tau
then it is truncated to tau.

wedge :: (Angle a, TrailLike p, V p ~ R2) => Double -> a -> a -> pSource

Create a circular wedge of the given radius, beginning at the first angle and extending counterclockwise to the second.

wedgeEx = hcat' (with & sep .~ 0.5) [ wedge 1 (0 :: Turn) (1/4) , wedge 1 (7/30 :: Turn) (11/30) , wedge 1 (1/8 :: Turn) (7/8) ] # fc blue # centerXY # pad 1.1

arcBetween :: (TrailLike t, V t ~ R2) => P2 -> P2 -> Double -> tSource

`arcBetween p q height`

creates an arc beginning at `p`

and
ending at `q`

, with its midpoint at a distance of `abs height`

away from the straight line from `p`

to `q`

. A positive value of
`height`

results in an arc to the left of the line from `p`

to
`q`

; a negative value yields one to the right.

arcBetweenEx = mconcat [ arcBetween origin (p2 (2,1)) ht | ht <- [-0.2, -0.1 .. 0.2] ] # centerXY # pad 1.1

annularWedge :: (Angle a, TrailLike p, V p ~ R2) => Double -> Double -> a -> a -> pSource

Create an annular wedge of the given radii, beginning at the first angle and extending counterclockwise to the second. The radius of the outer circle is given first.

annularWedgeEx = hcat' (with & sep .~ 0.50) [ annularWedge 1 0.5 (0 :: Turn) (1/4) , annularWedge 1 0.3 (7/30 :: Turn) (11/30) , annularWedge 1 0.7 (1/8 :: Turn) (7/8) ] # fc blue # centerXY # pad 1.1