I'm writing a program for users to quickly approximate the shape of a curved or straight bendable pipe with a quadratic bezier curve. They will enter the start and end points and provide the length of the pipe. An analogy would be someone staking down the start and end of a rope of known length.
In order to determine the shape of the curve they would click a point along the edge of the displayed pipe/rope shape where it "bows the furthest" from the start/end points. This is shown by the red cross in the diagram below. I'm showing the red cross not on the pipe to indicate that user's are allowed/likely to make an error in this selection. It seems unlikely they could select a point exactly on the curve.
Once the user has selected this point the result will be displayed as an SVG quadratic bezier: https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands
Given that the start and end points are two of the quadratic's control points. I'd like to calculate the third control point of the quadratic bezier assuming the start/end points and length are accurate. In other words, the red point should "tension" the curve in the direction of the third control point.
I'm imagining I could initially calculate the third control point assuming the user's click (red cross) is actually on the quadratic curve using this algorithm.
Given the three control points that define the curve I could then calculate the length of the curve using this equation.
If the curve's length is within an error tolerance I'm done. If not, I could iteratively move the third control point, recalculate the length, repeating until the control point puts the length within the desired tolerance.
How would I adjust the third control point's x,y location while still maintaining the shape of the curve?
Or is there a better solution overall?
Clarifications:
The domain here is the sport of dog agility. The intent is to allow users to identify "tube tunnel" shapes on an existing competition course diagram image. The course diagrams will give the tunnel lengths and the start and end locations as specified by the judge.
Only a very rough reproduction of the tunnel shape is required.
At dog agility events the tunnel end points will be located on the course via tape measure/measuring wheel at best w/in +/- 1 ft and then the tunnel is fully extended in a visual approximation of the shape and held in place by sandbags. No measurement of the shape is performed.
The idea for this application is to allow someone on a mobile phone to only click one point (generally) on the curve to create a visual starting point of the shape. The user will be able to further refine the shape if they desire.
There are only a few allowed tunnel lengths and shapes. Most, but not all, allowed shapes can be represented using a quadratic bezier, it will be used as a starting point while maintaining the start/end/length constraints.