views:

29

answers:

1

I'm working in flex, although I reckon this is a language independent problem. I'm trying to draw a curve using 3 points, using curveTo (a quadratic bezier function, I don't believe Flex has any other, if it does, please correct me!) Points 1 and 3 are "nodes", with point 2 being a drag handle.

What I want is not for the line to curve towards point 2 but in fact pass through it. I've managed to get this working by fluking it - by doubling the (distance between the midpoint of a line between Points 1 and 3) and Point 2.

This doesn't put it on the Apex of the line though, just somewhere close to it.

Anyone any ideas?

Andrew

A: 

the quadric bezier curve is calculate using the formula

B(t) = (1-t)(1-t)*P0 + 2(1-t)t*P1 + t*t*P2

where P0,P1 and P2 are the 3 points you specify. The curve starts in P0 and ends in P2 t ranges from 0 to 1 the apex should be reached at t = 0.5 so try to insert P0, P2 and t = 0.5 into the formula set it equal to the point where you want the apex to be and extract P1 from the formula

Nikolaus Gradwohl
Thanks for this, I'd already looked at the formula. The problem lies with the issue that the apex is not always at t = 0.5.
Andrew