Looking at the API docs for QuadCurve makes me think of having to fill in a 47-page contract just to get a train ticket. So how did you use that to draw a parabola?
Joined: Dec 27, 2002
Doing the parabola was the easiest of the three.
You need three points on the canvas p1, p2 and ptcontrol to depict it with QuadCurve2D.
a line from p1 to ptcontrol and a line from p2 to ptcontrol are two opposing tangents on the parabola. It makes an isoscles triangle.
And it turns out that if the focus is at (0,0)
and p1 is at, just for fun, (-3, +4) then I put the p2 point at (-3, -4).
This will put the p1 point at a distance of 5 from the focus ( a [3, 4, 5] right triangle.)
Now the real fun starts :
if you make a line from the focus to p1 and then make a line depicting the tangent, then let the angle between the two lines be "F". A line from p1 to ptcontrol also (!) makes the angle F with the x axis. This is because the distance from the focus to the ptcontrol is also 5 !!! Same as the distance from p1 to the focus. So there is another isoscles triangle.
And the best of all is that this angle F is half of the angle formed with the x axis by the [3, 4, 5] triangle. Arctan 3/5 = 2F.
Further points along the parabola can be predicted because the distance from the focus to the vertex (tip of the curve) is = d = (5 - 3)/2 and also the distance from the vertex to the directerix line. And the distance from the directerix to the ptcontrol is 3 (from the 3, 4, 5 triangle). So if p1 is (-3, 4) and p2 is (-3, -4) then ptcontrol is (-3 + 2d + 2*3, 0) = (5, 0).
From this I have the formula for the parabola x = -(y**2)/4d + d;
It is symetrical along the x axis and opens to the left.
If you differentiate the formula for the parabola then you have dy/dx and there is the slope of the tangent.
It all hangs together.
And thereby one can also determine if a "tilted" parabola is being depicted, and determine the angle of tilt.
I have this in an app where the satellite is at point p1, the gravity source is at the focus and the velocity vector is of course, the tangent. I start with the distance to the gravity source known (here 5), the angle between the satellite to gravity source line and the velocity vector is also known (here F).
And the rest falls into place nicely.
With a hyperbola it's kinkier. With a hyperbola you always have twins. So which one is the curve? I'm almost there.