我正在尝试制作一个需要 4 个参数的贝塞尔函数:
> import Diagrams.Backend.SVG.CmdLine
> import Diagrams.Prelude
> import Control.Applicative
> bezier4 x1 c1 c2 x2 = bezier3 (c1 ^-^ x1) (c2 ^-^ x1) (x2 ^-^ x1) # translate x1
> lineBtwPoints p1 p2 = fromOffsets [p2 ^-^ p1] # translate p1
> illustrateBézier x1 c1 c2 x2
> = endpt # translate x1
> <> endpt # translate x2
> <> ctrlpt # translate c1
> <> ctrlpt # translate c2
> <> l1
> <> l2
> <> fromSegments [bezier4 x1 c1 c2 x2]
> where
> dashed = dashingN [0.03,0.03] 0
> endpt = circle 0.05 # fc red # lw none
> ctrlpt = circle 0.05 # fc blue # lw none
> l1 = lineBtwPoints x1 c1 # dashed
> l2 = lineBtwPoints x2 c2 # dashed
>
> x1 = r2 (0.3, 0.5) :: R2
> x2 = r2 (3,-1) :: R2 -- endpoint
> [c1,c2] = map r2 [(1,2), (3,0)] -- control points
> example = illustrateBézier x1 c1 c2 x2
但结果似乎不是我想要的: