If you interpret your geometric shape as a NURBS of degree 1 (linear), you can proceed with the following, extremely simple code:
pts=pts = {{0, 0}, {1, 1}, {0.5, 1.5}}; (* just an example *)
s=BSplineFunction[ptss = BSplineFunction[pts, SplineClosed ->True> True, SplineDegree ->1];> 1];
Animate[ParametricPlot[s[t], {t, 0, 1}, Epilog :> {Red, PointSize[Large], Point[s[t]]}], {t, 0., 1.}]
This yields the triangular (outer) graph of the following display:
Just replace Animate
by Manipulate
to give the user control over the point.
Note This is a rather general approach applicable in wide areas, since you can vary your control points as well as the spline degree, but the BSplineFunctionBSplineFunction
will always yield the curve between arguments 0 and 1. In essence, you can display quite every geometric shape using this approach. For more complex ones, some adjustment to BSplineB-weightsspline weights will be necessary, though.
The inner of those curves result from the same control points as before, but degree 2 and weights explicitly given as SplineWeights -> {.1, 1, 1}
. Just exchange the s
-line above with this one:
s = BSplineFunction[pts, SplineClosed -> True, SplineDegree -> 2, SplineWeights -> {.1, 1, 1}];
I hope this might be of some help to you.