Search code examples
c#wpfpointbezier

Calculate middle point of Bezier Curve


I have a function to draw Bezier Curve through three points. I have already 2 points (start and end) - A and B. How do I calculate middle point between those two points as middle point would be always a little higher or lower than linear function of those two points.

Example:

enter image description here

Any formulas, ideas would be great!


Solution

  • I think this is what you're looking for:

    http://blog.sklambert.com/finding-the-control-points-of-a-bezier-curve/

    It goes into detail on calculating the various points on a Bezier curve.

    You may also be interested in this more specific example for your application:

    http://www.codeproject.com/Articles/223159/Midpoint-Algorithm-Divide-and-Conquer-Method-for-D

    If you really want to get into it, then I suggest this Primer:

    http://pomax.github.io/bezierinfo/

    Bezier curves are a bit more complicated than simple arcs. For an arc, you can just use this formula:

    R = H/2 + W^2/8H
    

    ...which definitely won't work for a Bezier curve. On a Quadratic Bezier curve, for example, to calculate a point, you must use:

    enter image description here

    Sources: http://en.wikipedia.org/wiki/B%C3%A9zier_curve, Quadratic Bezier Curve: Calculate Point