udibehar
(Ehud Behar)
January 2, 2021, 3:03pm
1
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
How do I that?
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}]
udibehar
(Ehud Behar)
January 2, 2021, 5:03pm
3
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.
hansmilton
(Hans Milton)
January 2, 2021, 7:18pm
4
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}
]
udibehar
(Ehud Behar)
January 2, 2021, 8:58pm
5
Yes, that’s what I am looking for!