This week's book giveaway is in the Performance forum.We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!

# Applet - Graphing Quadratic Function Help

Josh Crawford
Greenhorn
Posts: 11
Hi!

Im making an applet to graph a quadratic function...now im not going to be rude and say "tell me how to do it!" but i was just wondering if i could get some assistance on making it...

Now of course, i've had a go at it, and i've made an applet to display the z intercepts, y intercept, and vertex (turning point). This is determined by the user inputs of the three coefficients a, b, and c.

First question, is this all the information i will need?

Secondly, i am struggling to figure out how to put this information into a graph and make it a parabola...

Thank you very much for your help!

Ps. my applet is below if you wish to have a look, i've made a crude graph if that helps as well...

-Crawf

Campbell Ritchie
Sheriff
Posts: 49466
64
Morning.

You are trying to do two things at the same time; shouldnt' these be in different classes?

You seem to have the method for solving a quadratic equation worked out, also drawing a graph on screen.

As for finding curves, have you explored the java.awt.geom package in the API yet? You might find something to your advantage there.

CR

Josh Crawford
Greenhorn
Posts: 11
Yeah, they probably should be in two different classes, but im doing this for a school assignment, and the teacher isnt expecting anything brilliant, he wants it VERY simple, but it would make things easier that way hey?

I've explored the java.awt.geom package, but found nothing as to what i am trying to achieve unfortunately...is there another way to plot each point onto the graph and and draw lines from each point. wouldnt that be easier? maybe...

Thanks!

-Crawf

Campbell Ritchie
Sheriff
Posts: 49466
64
When I was a beginner in my first Java course, we were expected to have the correct number of classes from the very beginning. But now you have got this far without dividing into separate classes, finish it this time, and use more classes for your next exercise.

I've explored the java.awt.geom package
And you didn't find the QuadCurve2D classes?

Jeff Albertson
Ranch Hand
Posts: 1780
Originally posted by Campbell Ritchie:
When I was a beginner in my first Java course, we were expected to have the correct number of classes from the very beginning.

Young folks today....

Originally posted by Campbell Ritchie:
And you didn't find the QuadCurve2D classes?

It's not quite that easy -- QuadCurve2D is a quadratic parametric curve, not just a simple quadratic function. The OP would have to think a bit about tangent lines to calculate the control point...
[ June 08, 2006: Message edited by: Jeff Albertson ]

Campbell Ritchie
Sheriff
Posts: 49466
64
Sorry.

Jeff Albertson
Ranch Hand
Posts: 1780
Originally posted by Campbell Ritchie:
Sorry.

Maybe it's a good idea to think about tangents

Campbell Ritchie
Sheriff
Posts: 49466
64
from Jeff Albertson. Maybe it's a good idea to think about tangents
Agree.

Better than my flying off at a tangent.