Add haddocks

This commit is contained in:
2021-04-04 18:53:43 +02:00
parent d3821fc7b3
commit b3649597fa
5 changed files with 61 additions and 21 deletions
+12
View File
@@ -3,8 +3,15 @@ module Geometry.Bezier
import Geometry.Data
import Geometry.Vector
{- | A synonym describing a quadratic Bezier curve as three 'Point2's: start,
control and end.
-}
type BQuad = (Point2,Point2,Point2)
{- | Split a quadratic Bezier curve into two at a fractional point along the
curve.
If the fraction is not between 0 and 1, this will create backwards curves.
-}
splitBezierquad :: BQuad -> Float -> (BQuad,BQuad)
splitBezierquad (a,b,c) z
= ( ( a
@@ -17,11 +24,16 @@ splitBezierquad (a,b,c) z
)
)
{- | Split a quadratic Bezier curve into a given number of straight lines, and
return the list of points defining these lines.
-}
bQuadToLine :: BQuad -> Int -> [Point2]
bQuadToLine (a,_,c) 0 = [a,c]
bQuadToLine x i = let (l,r) = splitBezierquad x 0.5
in bQuadToLine l (i-1) ++ bQuadToLine r (i-1)
{- | Transform a quadratic Bezier curve into a function.
-}
bQuadToF :: (Point2,Point2,Point2) -> Float -> Point2
bQuadToF (c,b,a) t = t *.* (t *.* a +.+ (1-t) *.* b) +.+
(1-t) *.* (t *.* b +.+ (1-t) *.* c)