Java Graphing Help
Author |
Message |
ddrsakuramax
|
Posted: Sun Nov 01, 2009 3:31 pm Post subject: Java Graphing Help |
|
|
Hi,
prof recently gave a project and one part of it consists of graphing a polynomial.
Does anyone have a clue to do this???
we're using Netbeans FYI
Please help! thanks! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
OneOffDriveByPoster
|
Posted: Sun Nov 01, 2009 5:52 pm Post subject: Re: Java Graphing Help |
|
|
Some math and AWT should do the trick. If I recall correctly, polynomials have roots, are odd or even and local maxima and minima. Have these points and take the value of the polynomial at intervals to get other points and just draw lines to connect them. |
|
|
|
|
![](images/spacer.gif) |
chopperdudes
|
Posted: Mon Nov 02, 2009 10:42 pm Post subject: RE:Java Graphing Help |
|
|
well, i guess input the polynomial into the program (i.e. int y = x^3 + 3x^2 + x -4), and then loop thru x values, drawing a dot in the appropriate (x,y) cordinate on the screen. |
|
|
|
|
![](images/spacer.gif) |
Superskull85
|
Posted: Mon Nov 02, 2009 11:20 pm Post subject: Re: RE:Java Graphing Help |
|
|
chopperdudes @ Mon Nov 02, 2009 10:42 pm wrote: well, i guess input the polynomial into the program (i.e. int y = x^3 + 3x^2 + x -4), and then loop thru x values, drawing a dot in the appropriate (x,y) cordinate on the screen.
You could do that. However I would think that approach would be very slow, and may show some characteristics of the graph inaccurately. A better approach would be to use Calculus to calculate roots, intercepts, turning points, points of inflection, concavity, etc. From there you could find certain points along the curve to make the output smoother, and than just draw a line between each point.
Of course the Calculus approach requires knowledge of curve sketching, but that would be the best way to do I would think, and if you wanted to extend the program to include support for non-polynomial functions you should be able to. ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|