I am trying to move points from a multi-segmented bezier curve to one end of the curve using the following code which modified for my use from here. Only the last segment seems to give the desired behaviour. All other segments, basically just disappear or skip through briskly.
public Vector2[] MultiSegmentCubicCurveReduction(Path curve, float start, float end)
{
List<Vector2> pointsForSubpath = new List<Vector2>();
float oneMinusStart = 1f - start;
float oneMinusEnd = 1f - end;
float scale = (end - start) / (curve.NumPoints - 1);
for (int i = 0; i < curve.NumSegments; i++)
{
var a =
oneMinusStart * oneMinusStart * oneMinusStart * curve[3*i] +
3f * oneMinusStart * oneMinusStart * start * curve[3 * i + 1] +
3f * oneMinusStart * start * start * curve[3 * i + 2] +
start * start * start * curve[3 * i + 3];
var b = a + (3f * oneMinusStart * oneMinusStart * (curve[3 * i + 1] - curve[3 * i]) +
6 * start * oneMinusStart * (curve[3 * i + 2] - curve[3 * i + 1]) +
3 * start * start * (curve[3 * i + 3] - curve[3 * i + 2])) * scale;
;
var d = oneMinusEnd * oneMinusEnd * oneMinusEnd * curve[3 * i] +
3f * oneMinusEnd * oneMinusEnd * end * curve[3 * i + 1] +
3f * oneMinusEnd * end * end * curve[3 * i + 2] +
end * end * end * curve[3 * i + 3];
var c = d - (3f * oneMinusEnd * oneMinusEnd * (curve[3 * i + 1] - curve[3 * i]) +
6 * end * oneMinusEnd * (curve[3 * i + 2] - curve[3 * i + 1]) +
3 * end * end * (curve[3 * i + 3] - curve[3 * i + 2])) * scale;
pointsForSubpath.AddRange(new List<Vector2>() { a, b, c, d });
}
return pointsForSubpath.Distinct().ToArray();
}
UPDATE
The brisk movement I was having earlier was actually a reduction of control points to four regardless of the number of segments. Now I am getting the following behaviour. All the points for the first segment converge to one end point whiles all the points of the remaining segments converge to the other end point, resulting in a straight line.