Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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}
 ]

enter image description here

share|improve this question
    
Works perfectly with me: "10.0 for Microsoft Windows (64-bit) (June 29, 2014)". –  eldo Sep 1 at 3:46

2 Answers 2

up vote 6 down vote accepted

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

share|improve this answer
    
yes much better...was just being lazy but hopefully helpful –  ubpdqn Sep 1 at 4:24
    
Thank you so much. –  Putterboy Sep 1 at 7:02

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.

share|improve this answer
    
+1 for hopefully helpful :) –  belisarius Sep 1 at 4:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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