Calculating the bounding box of cubic bezier curve

后端 未结 3 873
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 16:09

I am trying to find an algorithm to calculate the bounding box of a given cubic bezier curve. The curve is in 3D space.

Is there a mathematic way to do this except o

3条回答
  •  醉梦人生
    2020-12-31 16:34

    Finding the bounding box of a cubic Bezier curve (or even B-spline curve of any degree) is typically done by finding the bounding box of the curve's control polygon. Since the curve is always bounded by its control polygon, the bounding box obtained via the control polygon is guaranteed to enclose the curve. You can also perform knot insertion to the curve and make the control polygon become closer to the curve itself. So, the general algorithm will go like this:

    1) Find the bounding box (denoted as BBox1) of the current B-spline curve from its control polygon.
    2) Insert knot at the mid-parameter of each Bezier segment in the B-spline curve.
    3) Find the bounding box (denoted as BBox2) of the new B-spline curve.
    4) Compare BBox2 against BBox1. If BBox2 is pretty much the same size as BBox1, we are done. If BBox2 is considerably smaller than BBox1, repeat step 2 to 4 until convergence.

提交回复
热议问题