Jump to content
  • Advertisement
Sign in to follow this  
daniel42

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by daniel42
I 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 this post


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

splines.png

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 this post


Link to post
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 this post


Link to post
Share on other sites
Thank you for your answers.

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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!