-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoint.java
91 lines (81 loc) · 1.61 KB
/
point.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
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
public class point implements PointInterface,Comparable<point>{
public float x;
public float y;
public float z;
public arraylist<triangle> cmntriangle;
public arraylist<point> cmnpts=new arraylist<point>();;
public point temppts;
public point(float x,float y,float z) {
this.x=x;
this.y=y;
this.z=z;
cmntriangle=new arraylist<triangle>();
}
public float getX() {
return x;
}
public float getY() {
return y;
}
public float getZ() {
return z;
}
public float [] getXYZcoordinate() {
float temp[]=null;
temp[0]=x;
temp[1]=y;
temp[2]=z;
return temp;
}
public int equal(point p) {
int count=0;
if(x==p.getX() && y==p.getY() && z==p.getZ()) {
return count;
}
else {
count=1;
return count;
}
}
public int compareTo(point p) {
if(x==p.x && y==p.y && z==p.z) {
return 0;
}
if(x>p.getX()) {
return -1;
}
else if(x<p.getX()) {
return 1;
}
else if(x==p.getX()) {
if(y>p.getY()) {
return -1;
}
else if(y<p.getY()) {
return 1;
}
else if(y==p.getY()) {
if(z>p.getZ()) {
return -1;
}
else if(z<p.getZ()) {
return 1;
}
else if(z==p.getZ()) {
return 0;
}
}
}
return 0;
}
public String toString() {
return Float.toString(x);
}
public double distance(point p) {
double f1= p.getX()-x;
double f2= p.getY()-y;
double f3= p.getZ()-z;
double d = f1*f1 + f2*f2 + f3*f3;
return d;
}
}