# help with b-splines

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

## Recommended Posts

Hi, I'm searching for help on a spline issue.
So,here is the situation:
I already have a bezier spline, defined by its two extremities, and the two control points to define the tangents. I use it to create a 2d polygon following the spline with a specified width. All this parameters can be modified by the user.

In order to give more control over the polygon, I now need to create two splines from the first one, each one being at an offset of (+|-) width/2. The issue is that this two splines, are not just "shifted" from the first one, as they are supposed to represent the sides of a road(with the first spline being the middle of the road).

So, to sum up, I need from one spline to create an approximation of a shifted spline created from the first one, all those splines being controlled by four points.

How can I compute the two control points of my shifted spline?

Thanks

##### Share on other sites
Quote:
 Original post by daniel42I already have a bezier spline, defined by its two extremities, and the two control points to define the tangents.

i'm not entirely sure what this means, but i'm assuming you have 4 control points.
Quote:
 How can I compute the two control points of my shifted spline?

why don't you just shift a new set of control points by the normal of the spline? It sounds like you're already doing something similar if you're creating a 2d polygon.

##### Share on other sites
I decided to add a picture illustrating my situation :

You can see here the first spline in the center, and two other splines, that I just shifted. The control points are the circles, so yes, I have 4 control points per spline.

Shifting the control point by the normal of the spline doesn't work either. At first sight, the wrongness of the result is not as obvious as it on the above picture, but the width of the polygon is still not kept along the spline. And by doing so, I can't keep the tangent at the extremities parallel.

##### Share on other sites
The only way you can do this is by either scaling the control points around the origin, or by translating them. You cannot do both at the same time (otherwise the curves will no longer relate to each other). Split the track into 90 degree curve sections or less, and it should work (i.e compose the road of lots of curve segments). This will work, but is probably a PITA. Certainly curves such as those you are attempting will not work.

I'd suggest going back to the drawing board for the moment and think about a single curve. If you were to compute the Frenet frame of the spline, you'd be able to use the resulting matrix to compute polygons that extend a fixed distance from each side of the spline to create a 'ribbon' for your road.

##### Share on other sites
The problem here is the curve you get by displacing the bezier curve is 'not' a bezier curve.

##### Share on other sites

I already have a way to create some kind of ribbon which extend the spline on both side, but the resulting polygon is then already discretized. The aim of getting two splines was to allow the user to easily change the shape of the ribbon by moving the control points(either those of the "central spline" which would keep a constant width, or those of the "side spline" which would then change the width along the spline). But by default I need to create the ribbon with a constant width.

So, I get that my "side splines" are not bezier spline anymore. Is there then a way to compute an "approximation" of these curve by a bezier spline?
I know two of the control points(the extremities), I know that the two other should be on the tangent at the extremities(as I want to keep the tangent parallel). But I couldn't find a way to compute the distance from each extremity to its associated control point on the tangent.

I tried to "guess" these distance by moving points along the tangent, and evaluating the distance between the expected discretized curve and the one generated by the spline, but computing it this way is too slow.

I tried to use the formula I could find on bezier spline to solve the equations choosing two points through which the spline should pass and an approximation of the curv distance at which they should be(approximation computed on the discretized curve), but I didn't get correct result, apparently because the approximation is too far from the true value.

Any advise about how to compute this approximation of the curve with 4 control points bezier spline?

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633665
• Total Posts
3013245
×