Plotting parametric curves

ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2  Pi}]

ParametricPlot[{1 + t^3, t - t^3}, {t, -1, 1}]

Weighted combinations

points = {{1, 2}, {3, 1}};
linearsegment = (1 - t) points[[1]] + 
          t points[[2]];

linearsegment

Table[linearsegment, {t, 0, 1, 0.1}]

ListPlot[%]

ParametricPlot[linearsegment, {t, 0, 1}]

points = {{0, 0}, {1, 1}, {2, 1}, {1, 
            0}};
p[t_] = (1 - t)^3 points[[1]] + 
          3 (1 - t)^2*t*points[[2]] + 
          3 (1 - t) t^2 points[[3]] + 
          t^3 points[[4]];

ListPlot[points, Axes -> False]

mypoints = Table[p[t], {t, 0, 1, 0.01}];
ListPlot[mypoints]

ParametricPlot[p[t], {t, 0, 1}, PlotRange -> All]

p[0]

p[1]

p'[0]

p'[1]

points = {{0, 0}, {1/2, -1}, {-1/2, 1}, {1, 
            0}};
n = Length[points];
p[t_] = 
        Sum[ Binomial[n - 1, k - 1] (1 - t)^(n - k) *t^(k - 1)*
            points[[k]], {k, 1, n}];
ParametricPlot[p[t], {t, 0, 1}, PlotRange -> All]

Next is an example of including multiple copies of a point.

points = {{0, 
            0}, {1/2, -1}, {1/2, -1}, {1/2, -1}, {1/
              2, -1}, {1/2, -1}, {1/2, -1}, {1/2, -1}, {1/
              2, -1}, {1/2, -1}, {1/2, -1}, {1/2, -1}, {1/
              2, -1}, {1, 0}};
n = Length[points];
p[t_] = 
        Sum[ Binomial[n - 1, k - 1] (1 - t)^(n - k) *t^(k - 1)*
            points[[k]], {k, 1, n}];
ParametricPlot[p[t], {t, 0, 1}, PlotRange -> All]

p[1/2. ]

p'[0.5]

points = {{0, 0}, {1, 1}, {-1, 3}, {2, 2}, {2, 
            0}};
n = Length[points];
p[t_] = 
        Sum[ Binomial[n - 1, k - 1] (1 - t)^(n - k) *t^(k - 1)*
            points[[k]], {k, 1, n}];
ParametricPlot[p[t], {t, 0, 1}, 
      PlotRange -> {{0, 2}, {0, 2}}]

Following Andy's suggestion, let's try using mypoints from above as the set of points on which we build a Bezier curve.  Nick's intuition is that this will result in a curve very similar to the curve that mypoints fall on.

points = mypoints;
n = Length[points];
p[t_] = 
        Sum[ Binomial[n - 1, k - 1] (1 - t)^(n - k) *t^(k - 1)*
            points[[k]], {k, 1, n}];
ParametricPlot[p[t], {t, 0, 1}, PlotRange -> All]

p'[0]

p'[1]

Alternative from class

In trying to come up with a useful weighted combination of four points, Alex first suggested the following.  Here's what we get.

points = {{0, 0}, {1, 1}, {2, 1}, {1, 
            0}};
p[t_] = (1 - t)^2 points[[1]] + 
          2 (1 - t)^2*t*points[[2]] + 
          2 (1 - t) t^2 points[[3]] + 
          t^2 points[[4]];
ParametricPlot[p[t], {t, 0, 1}, PlotRange -> All]

p[t]

Expand[p[t]]

The following confirm that this choice gives us a scaling factor of 2 for the initial and final tangent vectors.

p'[0]

p'[1]

Comparison with text's approach

In class, I claimed without proof that the weighted combination of four points we used is equivalent to the cubic Bezier curve we got by "brute force" on Tuesday (following the text's approach).  Here's a confirmation.  We will apply our weighted combination to four points using the text's notation from page 160 (with a and b in place of α and β for simplicity in typing).

points = {{x0, y0}, {x0 + a0, y0 + b0}, {x1 - a1, y1 - b1}, {x1, 
            y1}};
p[t_] = (1 - t)^3 points[[1]] + 
          3 (1 - t)^2*t*points[[2]] + 
          3 (1 - t) t^2 points[[3]] + 
          t^3 points[[4]];

p[t]

Expand[p[t]]

Collect[%, t]

You should compare this last result with Equations 3.24 and 3.25 on page 162.  Note that those use a scaling factor of 3 on the initial and final tangent vectors.