-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.java
More file actions
123 lines (112 loc) · 1.9 KB
/
Vertex.java
File metadata and controls
123 lines (112 loc) · 1.9 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* An entity class for a vertex.
*/
public class Vertex {
private double x;
private double y;
private double z;
/**
* Creates a vertex with the default position (0,0,0)
*/
public Vertex() {
x = 0;
y = 0;
z = 0;
}
/**
* Creates a vertex with the given x, y, z coordinates.
*
* @param x
* The x coordinate.
* @param y
* The y coordinate.
* @param z
* The z coordinate.
*/
public Vertex(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
/**
* Sets the x value.
*
* @param x
* The new x value.
*/
public void setX(double x) {
this.x = x;
}
/**
* Sets the y value.
*
* @param y
* The new y value.
*/
public void setY(double y) {
this.y = y;
}
/**
* Sets the z value.
*
* @param z
* The new z value.
*/
public void setZ(double z) {
this.z = z;
}
/**
* Sets the vertex to the given x, y, z coordinates.
*
* @param x
* The new x coordinate.
* @param y
* The new y coordinate.
* @param z
* The new z coordinate.
*/
public void setPosition(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
/**
* Gets the x value.
*
* @return The x value.
*/
public double getX() {
return x;
}
/**
* Gets the y value.
*
* @return The y value.
*/
public double getY() {
return y;
}
/**
* Gets the z value.
*
* @return The z value.
*/
public double getZ() {
return z;
}
/**
* Translates the vertex by the given amounts.
*
* @param xAmt
* The amount to translate on the X axis.
* @param yAmt
* The amount to translate on the Y axis.
* @param zAmt
* The amount to translate on the Z axis.
*/
public void translateXYZ(double xAmt, double yAmt, double zAmt) {
x += xAmt;
y += yAmt;
z += zAmt;
}
}