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

## Recommended Posts

Hi Guys, Not sure if an answer exists for this - google wasn't much help! I'm wondering if it's possible to calculate the position of the control point of a 2d quadratic curve given the two anchor points and a point that lies on the curve. This may seem backwards, but for my map editor i'd like to be able to drag any point on the curve to a new location and have the curve run through (or at least near) that point - kind of like the way the flash editor works - ideally I don't want to have to keep manipulating control points with the mouse. I'm guessing the answer will be an estimation (which is fine) as flash does not do this accurately and I doubt that the guys over at adobe missed something. Any help would be really appreciated. Cheers, Chris

##### Share on other sites
Let the endpoints be P0 and P2. Let Q be the point known to be on the curve. Let P1 be the control point you want to compute. The quadratic curve containing P0, Q, and P2 is of the form X(t) = P0 + t*A + t^2*B for 0 <= t <= 1. This already implies X(0) = P0. You need P2 = X(1) = P0 + A + B.

The problem is underdetermined because you do not know a value t' for which X(t') = Q. This is where an estimate is needed. Suppose that you started with a quadratic Bezier curve and the user selects a point Q on that curve. You can compute the corresponding value of t' from (1-t')^2*P0 + 2*(1-t')*t'*P1 + (t')^2*P2 = Q (solve the x-component for t', for example). Now if Q is not dragged very far from the curve, you can use t' as the value for which Q = X(t') = P0 + t'*A + (t')^2*B. Now you have two equations in two unknowns A and B.

If Q is dragged very far from the curve before you need A and B, you probably need a different algorithm for estimating t'. Perhaps choose t' = |Q - P0|/(|Q - P0| + |Q - P1|).

1. 1
2. 2
3. 3
Rutin
13
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633696
• Total Posts
3013391
×