- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdge.java
More file actions
Latest commit
60 lines (46 loc) · 1.43 KB
/
Copy pathEdge.java
File metadata and controls
60 lines (46 loc) · 1.43 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
publicclassEdgeimplementsEdgeInterface,Comparable<Edge> {
Point[] e=newPoint[2];
publicEdge(Pointp1,Pointp2){
e[0]=p1;
e[1]=p2;
}
publicPointInterface [] edgeEndPoints(){ returne; }
ArrayListForTrianglestriangles = newArrayListForTriangles();
publicvoidaddTriangle(Trianglet){
triangles.add(t);
}
publicArrayListForTrianglesgetTriangles(){
returntriangles;
}
publicbooleansame(float[] c){
return (e[0].same(c[0],c[1],c[2])&&e[1].same(c[3],c[4],c[5]))||(e[1].same(c[0],c[1],c[2])&&e[0].same(c[3],c[4],c[5]));
}
publicPointother(float[] c){
if (e[0].same(c))
returne[1];
returne[0];
}
publicPointother(Pointc){
if (e[0]==c)
returne[1];
returne[0];
}
@Override
publicintcompareTo(Edgeedge){
float[] c1=this.e[0].getXYZcoordinate(),c2=this.e[1].getXYZcoordinate();
floatdt=(float)Math.sqrt(Math.pow(c1[0]-c2[0],2)+Math.pow(c1[1]-c2[1],2)+Math.pow(c1[2]-c2[2],2));
c1=edge.e[0].getXYZcoordinate();
c2=edge.e[1].getXYZcoordinate();
floatde=(float)Math.sqrt(Math.pow(c1[0]-c2[0],2)+Math.pow(c1[1]-c2[1],2)+Math.pow(c1[2]-c2[2],2));
if (dt<de) return -1;
if (dt==de) return0;
return1;
}
publicintcompareTo(floatde){
float[] c1=this.e[0].getXYZcoordinate(),c2=this.e[1].getXYZcoordinate();
floatdt=(float)Math.sqrt(Math.pow(c1[0]-c2[0],2)+Math.pow(c1[1]-c2[1],2)+Math.pow(c1[2]-c2[2],2));
if (dt<de) return -1;
if (dt==de) return0;
return1;
}
}