Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.5K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Draw a Bézier curve using Manipulate and Locator

Posted 4 years ago

I want to draw a Bezier curve on the canvas using 2 end points and one control point (a quadratic Bézier curve).

What I came up until now is this:

Manipulate[
 Graphics[{{Point[p0]}, {Point[p1]}, {Point[p2]}},
  PlotRange -> 2, Frame -> True]
 , {{p0, {1, 1}}, Locator}
 , {{p2, {-1, -1}}, Locator}
 , {{p1, {-1, 1}}, Locator}
 ]

I want to draw now the curve enter image description here

How do I that?

POSTED BY: Ehud Behar
4 Replies
Posted 4 years ago

Yes, that's what I am looking for!

POSTED BY: Ehud Behar
Posted 4 years ago

Maybe like this?

Manipulate[
    ParametricPlot[
     (1 - t)^2 p0 + 2 (1 - t) t p1 + t^2 p2, {t, 0, 1},
     PlotRange -> 2, Frame -> True
    ],
    {{p0, {1, 1}}, Locator},
    {{p1, {-1, 1}}, Locator},
    {{p2, {-1, -1}}, Locator}
 ]
POSTED BY: Hans Milton
Posted 4 years ago

That's very helpful!

But what if I want to draw a curve c(t) which is not a built-in symbol in the Wolfram language?

In particular, I am planning to do some complex algebra on the curve's x and y components. So I would like rather to have its explicit definition given the control points, for future manipulation.

POSTED BY: Ehud Behar
Posted 4 years ago

Hi Ehud,

You can use the Graphics primitive BezierCurve.

Manipulate[
  Graphics[{{Point[p0]}, {Point[p1]}, {Point[p2]}, BezierCurve[{p0, p1, p2}]},
  PlotRange -> 2, 
  Frame -> True], 
  {{p0, {1, 1}}, Locator}, {{p2, {-1, -1}}, Locator}, {{p1, {-1, 1}}, Locator}]
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard