I’ve been struggling looking for an understandable way to do this. I have four points, a StartPt, EndPoint, and Intersection points to represent the peak and valley in the bezier.
The BezierSegment in C# requires start, controlPoint 1, controlPoint 2, endpoint – however I don’t have any control points I only have these two points that lie along the bezier curves (i’m calling them intersection points above)… how can I calculate the two control points?
Thanks in advance, this has been driving me crazy.
There’s some kind of explanation here: http://www.tinaja.com/glib/nubz4pts1.pdf but it’s written in postscript and that language makes no sense to me at all – it’s over my head.
There are an infinite number of solutions to a curve passing through 4 points, but the best simple solution is to try to make the curve segment lengths proportional to the chord lengths. The code you link to is the a first order approximation that works well and is pretty fast.
Here’s the C# translation of the PostScript code:
I haven’t tested it, but it compiles. Just call
DrawingUtility.BezierFromIntersectionwith the 4 points you have, and it will return aPathFigurefor drawing the curve.