-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint3d.java
42 lines (35 loc) · 958 Bytes
/
Point3d.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
/*
* Point3d --
*
* Diese Klasse repraesentiert einen Punkt im Raum. Die Koordinaten werden
* mit Array von 'double'-Werten dargestellt.
*
*/
public class Point3d
implements Comparable {
public double x, y, z;
public int mapIndex;
public Point3d () {
x = y = z = 0.0;
mapIndex = 0;
}
public Point3d (double x, double y, double z, int mapIndex) {
this.x = x;
this.y = y;
this.z = z;
this.mapIndex = mapIndex;
}
public static Point3d add (Point3d a, Point3d b) {
return new Point3d (a.x + b.x, a.y + b.y, a.z + b.z, a.mapIndex);
}
public static Point3d multiply (double a, Point3d b) {
return new Point3d (a * b.x, a * b.y, a * b.z, b.mapIndex);
}
public int compareTo (Object p) {
if (z < ((Point3d)p).z)
return -1;
if (z > ((Point3d)p).z)
return +1;
return 0;
}
}