How to build a smart bezier curve?

Started by
3 comments, last by Tangletail 10 years ago

I want to build a smart bezier curve like this. There are 100 targets (grid) in the map. I know the source point (Rocket), and the target point (Grid). How to calculate two control points to build a beautiful bezier curve which can not across the blue map?

bzH.png

Advertisement

I want to build a smart bezier curve like this. There are 100 targets (grid) in the map. I know the source point (Rocket), and the target point (Grid). How to calculate two control points to build a beautiful bezier curve which can not across the blue map?


"a beautiful bezier curve which" what?

If you know it will only ever be 100 targets and the position of the source is constant, it might be easiest to just generate all 100 of them manually.

If you need to come up with an algorithmic solution you would probably want to base it on whatever is aesthetically pleasing to you, and that is going to take a lot of work.

A variation of frobs idea:

Perhaps you can hard code the edge cases, and dynamically generate the easy cases where the ship/target are not near the edges?

You might also consider not using a curve, maybe doing it via physics? A steering system that considers the edges as something to avoid would do their best to not touch them. Though you do run into a problem where the object might not always make it perfectly to the point. (Which you can kind of fake if you really need it.)

How are you determining the curve? If you have points you know you want the thing to pass through, you could try catmull-rom, and then it's pretty easy to ensure that the catmull-rom control points are clamped to be inside the blue rectangle, which would mostly get you the curve you want. (Not perfect, you'd still run into cases where you might go outside)

Another thing you might want to do, is instead of using some sort of parameterized curve, use a Dubin's Curve instead, and adjust start angle or the min radius as necessary so that the curve doesn't go outside the bounds.

I am not quite sure I am following what you are asking here. You know two points. And you need two control points... I got that.

Why not just use the two points you have to form the two control points? If you are attempting to calculate trajectory, that is actually all you need unless your physics engine is some odd design.

If you mean, you do not want it to cross the map, I assume the grid, then you will want to use an invisible anchor that will collide with the grid, which effectively will cause the bezzier to adjust it's shape.

If you follow this idea, you will need to adjust it slightly so that the bezzier doesn't take such a large curve as well.

This topic is closed to new replies.

Advertisement