# Finding control points for a b-spline

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I was wondering if there was a was to automate the finding of control points for a b-spline, rather than trying to do it manually. Does anyone know of a program that would do that? -Matt

##### Share on other sites
Do you mean you have the curve first, and now you want the control points that form it? Because to do that, you can use some linear least squares solving. By setting up a big ugly matrix of values and using something like singular value decomposition to do the solve. I wish I knew it well enough to describe it to you , sorry :)

##### Share on other sites
Well, I have an idea of what I want the curve to be, but not an actual equation or anything. For example, for camera motion, I'd like the camera to rotate around the point it is looking at. I tried to guess control points, but the curve was not smooth and it looked really cheap.

##### Share on other sites
you mean you need to find control points to make a Bezier spline that match, say, circle? In this case you need to approximate circle with other polynomial spline such as Catmull-Rom that actually passes control points, by placing many enough control points on circle ("many enough" means many enough to make it look circlelike enough, as it will never be exactly circle), and then if you really need Bezier spline (and if piecewise Bezier is okay), you can convert each piece of Catmull-Rom to piece of cubic Bezier. (basically, you need to find control points for Bezier that makes Besier have same polynomial coefficients as Catmull-Rom). Essentially, cubic Bezier is the same as Catmull-Rom, except for control points.

Also, there's many different favours of Bezier, and if you use piecewise Bezier that passes control points and have derivatives defined in 'em, you could just compute derivatives of curve you want and set 'em.
If you use arbitrary-degree Bezier (aka true Bezier), you will have to make polynomial spline of same degree that pass control points, and then find points for Bezier. To make that polynomial spline of arbitrary degree, you'll need to do some complex enough stuff with matrices.

It is quite possible that you could just use different, more "friendly" spline instead of Bezier, spline that passes control points. So I will not get into details how to do that with Bezier, as it is definately not so simple and I don't sure you really need exactly that. It is generally better to just make spline that passes points.

##### Share on other sites
Quote:
 Original post by mattslav I tried to guess control points, but the curve was not smooth and it looked really cheap.

If the curve is not smooth that depends on the degree of the spline you are using (min degree=3 for 3D), or your point are too near each other.
If you want a simple circle, I think you need to define its bounding box taking into account the fact that the spline pass throught 2 point out of 4 (=degree+1). So the control points should be as follow:
  15    16   1   2    3     +---+---*---+---+     |               |  14 +               + 4     |               |  13 *               * 5     |               |  12 +               + 6     |               |     +---+---*---+---+    11   10   9   8     7

You have this way 16 control points. Note that you must begin from the middle of an edge (not from a corner), since in control point marked with "*" you have contact between the curve and the control polygon. (Of course you can use counter clockwise order (so 16 become 2, 15 become 3, ecc. or you can start from the bottom (9 become 1, 8 or 10 become 2, ...), ...).

Hope that helps.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631426
• Total Posts
3000019
×