7
$\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$
  • $\begingroup$ Works perfectly with me: "10.0 for Microsoft Windows (64-bit) (June 29, 2014)". $\endgroup$ – eldo Sep 1 '14 at 3:46
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

|improve this answer|||||
$\endgroup$
  • $\begingroup$ yes much better...was just being lazy but hopefully helpful $\endgroup$ – ubpdqn Sep 1 '14 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.

|improve this answer|||||
$\endgroup$
  • $\begingroup$ +1 for hopefully helpful :) $\endgroup$ – Dr. belisarius Sep 1 '14 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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