Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounding box feature #229

Open
Wzshun opened this issue May 26, 2023 · 5 comments
Open

Bounding box feature #229

Wzshun opened this issue May 26, 2023 · 5 comments

Comments

@Wzshun
Copy link

Wzshun commented May 26, 2023

Can it support the bounding box function.

For now I use this library to convert the self-defined spline to bspline, then call toBeziers(), then get their respective boxes, and then united them.

@msteinbeck
Copy link
Owner

I will have a look at how to compute the bounding box for B-Splines.

@msteinbeck
Copy link
Owner

It looks like there is no general analytical solution for computing the bounding box of a spline of any degree. For splines with degree 3 and less, your approach (converting the spline into a sequence of bezier curves, computing the bounding box of each bezier curve, and merging the bounding boxes into a single bounding box) seems to be the way to go. I could implement a function which applies these steps for spline of degree 3 and less, and falls back to a sampling based approach for spline of higher degree.

That said, sampling the spline and computing the bounding box of the resulting polyline (linear search for the minimum and maximum values) could serve as a first quick fix for your issue.

@msteinbeck
Copy link
Owner

It looks like that computing the bounding box analytically works only if a spline is function-like, i.e., the control points are monotonically increasing in x. Because TinySpline supports splines of any shape, the provided function will in most cases compute the bounding box numerically, i.e., by sampling the spline with a resolution.

@Wzshun
Copy link
Author

Wzshun commented Jun 30, 2023

Because TinySpline supports splines of any shape, the provided function will in most cases compute the bounding box numerically, i.e., by sampling the spline with a resolution.

It seems so. I found an awesome lib for spline, hope it works for you.
splines-lib

@msteinbeck
Copy link
Owner

msteinbeck commented Jul 2, 2023

SplineLib looks like a well-implemented library for splines. Does ExactBounds work with arbitrarily shaped splines, in particular, splines whose coordinates are not sorted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants