# Draw me a Hyperbola

Dave Elwood

Ranch Hand

Posts: 84

posted 5 years ago

I can draw an ellipse with Ellipse2D, a parabola with QuadCurve2D

but to make my conic section collection complete I'm trying to draw a hyperbola.

I've googled it to death, java docs have an aversion to using geometric nomenclature--in QuadCurve2D not one word about parabola !!!

Some applets bring up the curve but don't betray how they got it.

Shall I write my own code???

Just a class name would make my holidays.

but to make my conic section collection complete I'm trying to draw a hyperbola.

I've googled it to death, java docs have an aversion to using geometric nomenclature--in QuadCurve2D not one word about parabola !!!

Some applets bring up the curve but don't betray how they got it.

Shall I write my own code???

Just a class name would make my holidays.

Dave Elwood

Ranch Hand

Posts: 84

posted 5 years ago

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?

Dave Elwood

Ranch Hand

Posts: 84

posted 5 years ago

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.

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.

posted 5 years ago

On a more serious note, Dave: and thank you for sharing your specialized knowledge. Not many members here would have taken the time to explain in detail.

Paul Clapham wrote: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?

Dave Elwood wrote:[Everything you always wanted to know about drawing a parabola but were afraid to ask].

On a more serious note, Dave: and thank you for sharing your specialized knowledge. Not many members here would have taken the time to explain in detail.

luck, db
*There are no new questions, but there may be new answers.*

Dave Elwood

Ranch Hand

Posts: 84

posted 5 years ago

I'm a year younger than you, a retired Electrical engineer in India, and in the habit of posting hints that are as brief as possible

Dave Elwood wrote:Thanks Darryl.

I'm a 61 year old English teacher in Germany. Have you ever met a teacher who wasn't ready to 'show you the way?'

I'm a year younger than you, a retired Electrical engineer in India, and in the habit of posting hints that are as brief as possible

luck, db
*There are no new questions, but there may be new answers.*