-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint3D.java
More file actions
61 lines (47 loc) · 1020 Bytes
/
Copy pathPoint3D.java
File metadata and controls
61 lines (47 loc) · 1020 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.util.ArrayList;
public class Point3D {
private float x;
private float y;
private float z;
public Point3D(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
}
public float getDistance(Point3D p) {
Vector3D v = new Vector3D(this, p);
return v.getModulo();
}
public void round(int decimals) {
float precision=decimals*10;
x=(float)Math.round(x * precision) / precision;
y=(float)Math.round(y * precision) / precision;
z=(float)Math.round(z * precision) / precision;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
public float getZ() {
return z;
}
public void setX(float x) {
this.x = x;
}
public void setY(float y) {
this.y = y;
}
public void setZ(float z) {
this.z = z;
}
public static void printPoints(ArrayList<Point3D>points) {
for(Point3D p:points) {
printPoint(p);
}
}
public static void printPoint(Point3D p) {
System.out.println("( "+p.getX()+" , "+p.getY()+" , "+p.getZ()+" )");
}
}