java Graphing
Author |
Message |
andy_tok
|
Posted: Thu Jan 11, 2007 5:46 pm Post subject: java Graphing |
|
|
Hi!
I tried to graph a parabola like y=x^2 by connecting points use Line2D.double but the resolution is pretty low. What's the better way? or I made a mistake somewhere?
Thanks
import java.applet.*;
import java.awt.*;
import java.awt.geom.*;
public class Gra2D extends Applet
{
public void paint (Graphics g)
{
Graphics2D t=(Graphics2D)g;
t.setColor(Color.black);
double x=0.00;
double y=0.00;
while(x<=500&&y<=500)
{
double xp=x+0.001;
double yp=xp*xp;
Line2D.Double ln= new Line2D.Double(x,y,xp,yp);
t.draw(ln);
x=xp;
y=yp;
}
} // paint method
} // Gra2D class |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|