I am using the code from the question here to create bezier curves (I didn't think it was necessary to repost the code here since I haven't made any significant changes to it yet).

I have a symmetric bezier curve (please see image) that I want to reduce till all points converge at the midpoint of the original curve. I would like to preserve it's symmetry while it moves. I would like achieve this using a float slider (with values from 0 to 1) in editor mode.

enter image description here

  • \$\begingroup\$ Your image suggests you're just rescaling it, but I could also interpret it as you wanting the reduction to follow along the path of the curve as well. Difference is that the line never moves, only how much of it is visible. Which are you looking for? And do you need a new curve for other reasons, or just need less of the curve to be visible? \$\endgroup\$ Sep 7, 2018 at 15:18
  • \$\begingroup\$ @ChrisMills-Price I am interested in the latter, the reduction following along the curve path. The original curve is symmetric, so I need it to reduce symmetrically till it reaches the midpoint. I need a new symmetric curve to be formed for each slider value from zero to one. \$\endgroup\$ Sep 7, 2018 at 16:02

1 Answer 1


Assuming you have a cubic Bezier curve type with control points a, b, c, d, and methods to evaluate, given a parameter 0 <= t <= 1, both:

  • a position on the curve at t

    ie. \$\vec p = (1-t)^3 \vec a + 3 t (1-t)^2 \vec b + 3 t^2(1-t) \vec c + t^3 \vec d\$

  • the first derivative of that position with respect to the parameter t

    ie. \$\frac {\delta \vec p} {\delta t} = 3 (1-t)^2 (\vec b - \vec a) + 6 t (1-t) (\vec c - \vec b) + 3 t^2 (\vec d - \vec c)\$

Then we can choose new control points for an arbitrary interval start <= t <= end on this curve like so:

static CubicBezier IntervalFromTo(CubicBezier curve, float start, float end) {

    float scale = (end - start)/3f;

    var a = curve.PositionAt(start);

    var b = a + curve.DerivativeAt(start) * scale;

    var d = curve.PositionAt(end);

    var c = d - curve.DerivativeAt(end) * scale;

    return new CubicBezier(a, b, c, d);

If you have a size parameter that runs between 0 (just the midpoint) and 1 (the whole original curve), then you can compute your symmetrical subset as a special case:

subsetCurve = IntervalFromTo(originalCurve, 0.5f - 0.5f * size, 0.5f + 0.5f * size);

I recommend that you keep your originalCurve unchanged throughout this manipulation, and make a fresh subsetCurve from the original each time something changes, rather than overwriting your original with each change. Keeping this separation will ensure you don't get unwanted vibrations or degradation due to accumulating rounding errors.

  • \$\begingroup\$ I'm not sure I understand the original question, but is this what they want, or just a simple rendering of t going from, 0% to 100%, then 10% to 90%, then 20% to 80%, etc. until it's just the point at t=0.5? \$\endgroup\$ Sep 8, 2018 at 1:01
  • \$\begingroup\$ Sorry for not replying earlier, haven’t been here for a few days. I’m using the code in gamedev.stackexchange.com/questions/159583/…, the only difference is I added a LineRenderer to PathCreator for the path. I am not sure how I’ll get the subPath to display the line since the the original curve’s line is linked to the pathCreator and all other path functionality is linked to the original path in the editor. Please see the related parts of the editor class in pastebin.com/9zkLtMBP. \$\endgroup\$ Sep 11, 2018 at 18:52
  • \$\begingroup\$ Thanks for your assistance. Using the code you provided, the bezier curve points converge to a midpoint different from the original curve hence the shape isn't maintained as this happens. The curve flattens into a straight line. I wanted the curve shape to be maintained as the points converge (with the two end points moving along the curve) to the midpoint of the original curve. Also, this process is irreversible. Any attempt to change the size value back to 1.0 still leaves the all points at a midpoint. \$\endgroup\$ Sep 13, 2018 at 12:05
  • 1
    \$\begingroup\$ Ask a new question, @Hilarious404. You can link to this one for context. \$\endgroup\$
    – DMGregory
    Sep 28, 2018 at 18:42
  • 1
    \$\begingroup\$ Use the same formulas, keeping end = 1 and blending start from 0 toward 1. \$\endgroup\$
    – DMGregory
    Oct 8, 2018 at 16:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .