Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CC[m_, t_] := Module[{n, M, a},
- n = Dimensions[m][[1]] - 1;
- M = Table[0, {i, 0, n}, {j, 0, n - i}];
- a = Table[" ", {i, 0, n + 1}];
- M[[1]] = m;
- a[[1]] = ListPlot[m, Joined -> True, DisplayFunction -> Identity];
- For[i = 1, i <= n, i++,
- For[j = 1, j <= n - i + 1, j++,
- M[[i + 1, j]] = t*M[[i, j + 1]] + (1 - t)*M[[i, j]]];
- a[[i + 1]] =
- ListPlot[M[[i + 1]], Joined -> True,
- PlotStyle -> RGBColor[i/n, 0, 1 - i/n],
- DisplayFunction -> Identity]];
- a[[n + 1]] =
- ListPlot[M[[n + 1]], PlotStyle -> PointSize[0.05],
- DisplayFunction -> Identity];
- a[[n + 2]] =
- ParametricPlot[
- Sum[Binomial[n, k]*s^k*(1 - s)^(n - k)*m[[k + 1]], {k, 0, n}], {s,
- 0, t}, PlotStyle -> {RGBColor[1, 0, 0], Thickness[0.02]},
- DisplayFunction -> Identity];
- Show[a, DisplayFunction -> $DisplayFunction,
- AspectRatio -> Automatic, PlotRange -> All, Axes -> False]]
- (test)
- m = {{0, 0}, {0, 1}, {1, 1}, {2, 0}, {3, 1}};
- Animate[CC[m, t], {t, 0.01, 1}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement