8
$\begingroup$

I tried to create an adjustable Bézier curve with the following simple code. However the curve didn't show up. What is the problem? Please help.

pts = {{0, 0}, {1, 2}, {2, 0}, {3, 3}};
bez = BezierFunction[pts ];

Manipulate[
 Show[Graphics[{Red, Point[lo], Green, Line[lo]}, Axes -> True], 
  ParametricPlot[bez[lo ], {t, 0, 1}], ImageSize -> { 200, 200 }],
 {{lo, pts}, Locator}
 ]

Bézier curve Manipulate

$\endgroup$
1
  • $\begingroup$ Works perfectly with me: "10.0 for Microsoft Windows (64-bit) (June 29, 2014)". $\endgroup$
    – eldo
    Commented Sep 1, 2014 at 3:46

2 Answers 2

8
$\begingroup$

Perhaps more compact:

Manipulate[
 ParametricPlot[BezierFunction[lo]@t, {t, 0, 1}, Epilog -> {Green, Line[lo]}], 
 {{lo, pts}, Locator}, 
 Initialization :> (pts = {{0, 0}, {1, 2}, {2, 0}, {3, 3}})]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ yes much better...was just being lazy but hopefully helpful $\endgroup$
    – ubpdqn
    Commented Sep 1, 2014 at 4:24
6
$\begingroup$

I believe this should achieve your aim:

Manipulate[
 bez = BezierFunction[lo];
 Show[Graphics[{Red, Point[lo], Green, Line[lo]}, Axes -> True], 
  ParametricPlot[bez[t], {t, 0, 1}], 
  ImageSize -> {200, 200}], {{lo, pts}, Locator}, 
 Initialization :> (pts = {{0, 0}, {1, 2}, {2, 0}, {3, 3}};)]

Quit kernel and try. Note: (i) the dynamic variable is the lo. pts are merely initial configuration (ii) the Bezier function $bez: [0,1]\mapsto R^2$-> t not lo as argument.

$\endgroup$
1
  • $\begingroup$ +1 for hopefully helpful :) $\endgroup$ Commented Sep 1, 2014 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.