-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSphere.java
More file actions
38 lines (32 loc) · 741 Bytes
/
Sphere.java
File metadata and controls
38 lines (32 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.List;
public class Sphere
{
public Vector pos;
public Vector vel;
public Vector force;
public double radius;
public double mass;
public List<ArrayList<Sphere>> list;
public Sphere(Vector pos, Vector vel, double radius, double mass)
{
this.pos = pos;
this.vel = vel;
this.force = new Vector(0.0, 0.0);
this.radius = radius;
this.mass = mass;
list = new ArrayList<ArrayList<Sphere>>();
}
public void paint(Graphics2D g)
{
g.drawOval((int)Math.rint(pos.x - radius),
(int)Math.rint(pos.y - radius),
(int)Math.rint(radius * 2.0),
(int)Math.rint(radius * 2.0));
}
public String toString()
{
return "pos: "+pos+" vel: "+vel;
}
}