-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTetrahedron.java
58 lines (49 loc) · 1.23 KB
/
Tetrahedron.java
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.awt.Point;
import java.awt.Color;
import java.awt.Graphics;
public class Tetrahedron {
private Color color;
private MyPolygon[] polygons;
public Tetrahedron(Color color, MyPolygon... polygons) {
this.color = color;
this.polygons = polygons;
this.setPolygonColor();
this.sortPolygons();
}
public Tetrahedron(MyPolygon... polygons) {
this.polygons = polygons;
this.sortPolygons();
}
public void render(Graphics g, Point3D center) {
for (MyPolygon a : this.polygons) {
a.render(g, center);
}
}
public void render(Graphics g) {
for (MyPolygon a : this.polygons) {
a.render(g);
}
}
public void sortPolygons() {
MyPolygon.sortPolygons(this.polygons);
}
public MyPolygon[] getPolygons() {
return this.polygons;
}
public void rotate(boolean CW, Point3D a, double xDegrees, double yDegrees, double zDegrees) {
for (MyPolygon p : polygons) {
p.rotate(CW, a, xDegrees, yDegrees, zDegrees);
}
sortPolygons();
}
public void move(double x, double y, double z) {
for (MyPolygon a : this.polygons) {
a.move(x,y,z);
}
sortPolygons();
}
public void setPolygonColor() {
for(MyPolygon a : this.polygons)
a.setColor(this.color);
}
}