Post Reply 
finding the minimum bounding box of a Bézier curve
11-08-2023, 01:35 AM
Post: #1
finding the minimum bounding box of a Bézier curve
I needed a way to compute the minimum bounding box for a cubic Bézier curve. For somewhat dumb reasons, this is involved in preparing my new SVG scalable graphics for Nonpareil II. Most or all vector drawing programs, including Inkscape), allow you to use cubic Bézier curves, usually by positioning control points. There are four control points for a cubic Bézier curve; the first and last are the end points of the curve, and other two control points affect how the curve behaves between the endpoints. It is a property of the Bézier curve that the curve never goes outside the convex hull of the control points. However, the minimum bounding box in many cases is much smaller, and it is often useful to have a bounding rectangle parallel to the coordinate axes, rather than an arbitrary convex hull.

I wanted to experiment with this, and the existing graphics programs and interactive web pages didn't quite do what I wanted, so I wrote a new C++ program using Qt, which will show a curve, allow you to drag the points around, shows the coordinates of the control points in a second pane, and can optionally show the bounding box of the control points, the convex hull of the control points, and the minimum bounding box of the curve.

It's open source, and the source code and a Windows .msi can be found at:
https://github.com/brouhaha/bezier-hack

A Bézier curve is defined by parametric equations, one per dimension of the curve, for a parameter t that ranges from 0 to 1. The way to find the minimum bounding box is to generate the polynomials for the parametric equations, differentiate them, and solve the differentials for zeros. Complex solutions can be discarded. The real solutions between 0 and 1 indicate at what parameter value(s) the cuve has minima or maxima. The minimum bounding box is then the minimum rectangle that contains the first and last control point, and any minima and maxima points.

It's probably very easy to do this on a graphing calculator that has symbolic differentiation, but I've only done it in C++ so far.
Find all posts by this user
Quote this message in a reply
11-08-2023, 12:21 PM
Post: #2
RE: finding the minimum bounding box of a Bézier curve
Open curves examples.. https://cubic-bezier.com/#.17,.67,.83,.67
Lea VEROU could perhaps support?
Could not see in your request if this is a closed or an open curve or what you want to achieve (a graph would be good).

HP71 4TH/ASM & Multimod, HP41CV/X & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X, HP75D
Find all posts by this user
Quote this message in a reply
11-08-2023, 06:31 PM
Post: #3
RE: finding the minimum bounding box of a Bézier curve
Thanks, but I wasn't requesting anything. The program is written and released as open source.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)