1 |
duarte |
226 |
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> pointsInBox; |
12 |
|
|
|
13 |
|
|
public Box(Point3i floor){ |
14 |
|
|
this.floor=floor; |
15 |
|
|
pointsInBox = new TreeMap<Integer, Point3d>(); |
16 |
|
|
} |
17 |
|
|
|
18 |
|
|
public void putPoint(int serial, Point3d point){ |
19 |
|
|
pointsInBox.put(serial, point); |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
public void getDistancesWithinBox(double[][] distMatrix){ //we pass a reference to the distMatrix that we alter within this method |
23 |
|
|
for (int i_serial:pointsInBox.keySet()) { |
24 |
|
|
for (int j_serial:pointsInBox.keySet()) { |
25 |
|
|
if (j_serial>i_serial){ |
26 |
|
|
// this only works if previously we have made sure that atom serials are sequential from 0 to MAXATOMSERIAL |
27 |
|
|
distMatrix[i_serial][j_serial] = pointsInBox.get(i_serial).distance(pointsInBox.get(j_serial)); |
28 |
|
|
} |
29 |
|
|
} |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
public void getDistancesToNeighborBox(Box nbBox ,double[][] distMatrix){ |
35 |
|
|
for (int i_serial:pointsInBox.keySet()){ |
36 |
|
|
for (int j_serial:nbBox.pointsInBox.keySet()){ |
37 |
|
|
if (j_serial>i_serial){ |
38 |
|
|
// this only works if previously we have made sure that atom serials are sequential from 0 to MAXATOMSERIAL |
39 |
|
|
if (distMatrix[i_serial][j_serial]==0.0){ // i.e. if we haven't passed through this cell yet |
40 |
|
|
distMatrix[i_serial][j_serial] = pointsInBox.get(i_serial).distance(nbBox.pointsInBox.get(j_serial)); |
41 |
|
|
} |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
} |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
} |