// Helene Martin, Garfield AP CS
// Demonstrates usage of return values, the Math class and DrawingPanel
// Should be a somewhat compelling example -- much prettier than graphing calcs
import java.awt.*;

public class MathGraph {
	public static void main(String[] args) {
		DrawingPanel p = new DrawingPanel(500, 500);
		Graphics g = p.getGraphics();
		// axes
		g.drawLine(0, 250, 500, 250);
		g.drawLine(250, 0, 250, 500);
		
		for(int x = -500; x < 500; x++) {
			g.setColor(Color.BLUE);
			g.fillOval(x + 250, (int)(250 - 100 * Math.sin(Math.toRadians(x))), 5, 5);
			g.setColor(Color.GREEN);
			g.fillOval(x + 250, (int)(250 - 100 * Math.cos(Math.toRadians(x))), 5, 5);
			g.setColor(Color.RED);
			g.fillOval(x + 250, (int)(250 - f(x)), 5, 5);
			System.out.println("X: " + x + ", Y: " + f(x));
		}
	}
	
	// You can define arbitrary functions to graph or use values from
	public static double f(int x){
		return 1 * Math.pow(x, 2) / 100;
	}
}
