Search code examples
algorithmbezier

An algorithm to find bounding box of closed bezier curves?


I'm looking for an algorithm to find bounding box (max/min points) of a closed quadratic bezier curve in Cartesian axis:

input: C (a closed bezier curve)
output: A B C D points

Image http://www.imagechicken.com/uploads/1270586513022388700.jpg

Note: above image shows a smooth curve. it could be not smooth. (have corners)


Solution

  • Well, I would say you start by adding all endpoints to your bounding box. Then, you go through all the bezier elements. I assume the formula in question is this one:

    Quadratic Bezier from Wikipedia

    From this, extract two formulas for X and Y, respectively. Test both for extrema by taking the derivative (zero crossings). Then add the corresponding points to your bounding box as well.