source: src/main/java/bargainingchips/etc/Paraboloid.java@ 343

Last change on this file since 343 was 316, checked in by Tim Baarslag, 5 years ago

new packages complete

File size: 1.4 KB
Line 
1package bargainingchips.etc;
2
3import java.awt.Canvas;
4import java.awt.Color;
5import java.awt.Graphics;
6
7
8/**
9 * @author Faria Nassiri-Mofakham
10 *
11 */
12public class Paraboloid extends Canvas{
13
14 /**
15 *
16 */
17 private static final long serialVersionUID = 1L;
18
19 Color color;
20 int length;
21 double a,b,c;//,d;
22
23
24 public Paraboloid(Color col, int l, double aa, double bb, double cc)//, double dd)
25 {
26 color=col;
27 length=l;
28 a=aa;
29 b=bb;
30 c=cc;
31// ?d=dd;
32 }
33
34 public void paint(Graphics g)
35 {
36 g.setColor(color);
37 g.drawLine(g.getClipBounds().x,g.getClipBounds().y, g.getClipBounds().x+length,g.getClipBounds().y);
38
39 g.setColor(Color.red);
40 for (double x=-100;x<=100;x = x+0.1){
41 double y = a * x * x + b * x + c;
42 int X = (int)Math.round(200 + x*20);
43 int Y = (int)Math.round(200 - y*20);
44 g.fillOval(X-2,Y-2,4,4);
45
46 y = - (x + 4) * (x + 4) - 7;
47 X = (int)Math.round(200 + x*20);
48 Y = (int)Math.round(200 - y*20);
49 g.fillOval(X-2,Y-2,4,4);
50
51
52// for (double x=-100;x<=100;x = x+0.1){
53// double z = a * x * x * x + b * x * x + c;
54//
55// double y = a * x * x + b * x + c;
56// int X = (int)Math.round(200 + x*20);
57// int Y = (int)Math.round(200 - y*20);
58// g.fillOval(X-2,Y-2,4,4);
59
60
61 }
62
63 }
64
65}
Note: See TracBrowser for help on using the repository browser.