1 |
package proteinstructure; |
2 |
|
3 |
import java.util.TreeMap; |
4 |
import javax.vecmath.Point3d; |
5 |
import javax.vecmath.Point3i; |
6 |
|
7 |
public class Box { |
8 |
|
9 |
Point3i floor; |
10 |
|
11 |
private TreeMap<Integer,Point3d> i_pointsInBox; |
12 |
private TreeMap<Integer,Point3d> j_pointsInBox; |
13 |
|
14 |
public Box(Point3i floor){ |
15 |
this.floor=floor; |
16 |
i_pointsInBox = new TreeMap<Integer, Point3d>(); |
17 |
j_pointsInBox = new TreeMap<Integer, Point3d>(); |
18 |
} |
19 |
|
20 |
public void put_i_Point(int serial, Point3d point){ |
21 |
i_pointsInBox.put(serial, point); |
22 |
} |
23 |
|
24 |
public void put_j_Point(int serial, Point3d point){ |
25 |
j_pointsInBox.put(serial, point); |
26 |
} |
27 |
|
28 |
public void getDistancesWithinBox(double[][] distMatrix, boolean directed){ //we pass a reference to the distMatrix that we alter within this method |
29 |
for (int i_serial:i_pointsInBox.keySet()) { |
30 |
for (int j_serial:j_pointsInBox.keySet()) { |
31 |
if (!directed) { |
32 |
if (j_serial>i_serial) { |
33 |
// this only works if previously we have made sure that atom serials are sequential from 0 to MAXATOMSERIAL |
34 |
distMatrix[i_serial][j_serial] = i_pointsInBox.get(i_serial).distance(j_pointsInBox.get(j_serial)); |
35 |
} |
36 |
} else { |
37 |
distMatrix[i_serial][j_serial] = i_pointsInBox.get(i_serial).distance(j_pointsInBox.get(j_serial)); |
38 |
} |
39 |
} |
40 |
} |
41 |
|
42 |
} |
43 |
|
44 |
public void getDistancesToNeighborBox(Box nbBox ,double[][] distMatrix, boolean directed){ |
45 |
for (int i_serial:i_pointsInBox.keySet()){ |
46 |
for (int j_serial:nbBox.j_pointsInBox.keySet()){ |
47 |
if (!directed) { |
48 |
if (j_serial>i_serial) { |
49 |
// this only works if previously we have made sure that atom serials are sequential from 0 to MAXATOMSERIAL |
50 |
if (distMatrix[i_serial][j_serial]==0.0){ // i.e. if we haven't passed through this cell yet |
51 |
distMatrix[i_serial][j_serial] = i_pointsInBox.get(i_serial).distance(nbBox.j_pointsInBox.get(j_serial)); |
52 |
} |
53 |
} |
54 |
} else { |
55 |
distMatrix[i_serial][j_serial] = i_pointsInBox.get(i_serial).distance(nbBox.j_pointsInBox.get(j_serial)); |
56 |
} |
57 |
} |
58 |
} |
59 |
} |
60 |
|
61 |
// Beware, this returns only the size for i |
62 |
public int size() { |
63 |
return i_pointsInBox.size(); |
64 |
} |
65 |
|
66 |
} |