2
votes

Hi stackoverflow's users !

First i want to say its my first post and i've been diging straight up gold from this site and i love it and everyone out there smart enough to give out solutions.

So basically am writing a game and i have bezier curve that controls where an actor moves. Am using only 3 points (start, control1, end) and everything is fine.

Now i want to create a bezier curve that passes through a certain point (r1) at t = 0.5 . The problem being that i have my start point, my end point and my point (r1) at t=0.5, and i need to find the control point.

Sorry if i explained it badly i hope everyone can understand.

Thank you for any replies : )

2
is r1 is the mid-point (or the crest) between the start and end points of the curve? - Chunky Chunk
A bezier curve needs two control points. Have you merge your points together? Or do you have some other simplification? - John Alexiou
@ja72: ActionScript3's drawing API currently only supports bezier curves with one control point. "real" bezier curves with 2 control points is coming in Flash Player 11. - Chunky Chunk
@ja72: of course, that's only if you're using the drawing API and not rolling your own curves. - Chunky Chunk
yes, r1 is the midpoint, you can use from 2 to n points for bezier curves if am correct - user745739

2 Answers

3
votes

Look into the documentation of Asymptote (here) which has a geometrical interpretation of the a spline. For the mid point (t=-.5) the point lies in the point m_5 below. If you are using one control point them c_0 and c_1 are coincident simplifying the math. If at (t=0.5) your y values is y_c and the beginning and ending values are respectively z_0 and z_1 then the control point is at

c = (8*y_c-z_0-z_1)/6

Do the same for the x values.

enter image description here

0
votes

Check out the question I asked a couple of days ago: Given f(x) linear function, how to obtain a Quadratic Bezier control point. I think it's exactly what you need.