CDMS/src/CDMS/kscheck
diff -u -r1.6 -r1.7
--- CreateRoadMapFile.java 31 Jan 2011 04:11:11 -0000 1.6
+++ CreateRoadMapFile.java 5 Feb 2011 20:45:38 -0000 1.7
@@ -28,7 +28,7 @@
* @return file with OGP commands that drive along TES lines taking pictures
*
*/
-public class CreateRoadMapFile {
+public class CreateRoadMapFile extends MapUtil{
private List<Double[]> _coordinates;
// public BasicMatrix XcoordsMatrix;
@@ -46,61 +46,50 @@
private static double nPixX = 620; //number of pixels in horizontal direction = 640 add overlap explicitly here: 620/460
private static double nPixY = 460; //number of pixels in vertical direction = 480
+ private static double pixelSize = 0.00059;
+
+ private static double xDim = nPixX * pixelSize;
+ private static double yDim = nPixY * pixelSize;
+
private static double OVERLAP_FRAC = 0.8;
- private static double xDim;
- private static double yDim;
+
private static boolean CHECK_OVERLAP = true; // flag for whether we check for overlap before interpolating
private static double BIG_CUTOFF = 2;
private static double HUGE_CUTOFF = 10; // cutoff for big jump, where we should interp forward to complete loop
- public CreateRoadMapFile(String inputCoordsFile, String outputOGPscript, double pixelSize, int outputType) throws FileNotFoundException, IOException {
+ private int debug;
+ private int ncoords;
+ BufferedWriter output;
+
+ public CreateRoadMapFile(String inputCoordsFile, String outputOGPscript, int outputType) throws FileNotFoundException, IOException {
// outputType = 0 should be default: normal commands file
// outputType = 1 is for csv output, for examining in excel/numbers/neooffice
-
- FileReader fr = new FileReader(inputCoordsFile);
- StreamTokenizer tok = new StreamTokenizer(fr);
- tok.resetSyntax();
- tok.wordChars(33, 126);
- tok.parseNumbers();
- tok.whitespaceChars(0, 32);
- tok.eolIsSignificant(true);
FileWriter fw = new FileWriter(outputOGPscript);
- BufferedWriter output = new BufferedWriter(fw);
-
- _coordinates = new ArrayList<Double[]>();
-
- xDim = nPixX*pixelSize;
- yDim = nPixY*pixelSize;
-
-
- // Loop over the input coordinate file entries
- while (true) {
- List<Double> args = getNumbersInLine(tok);
-
- //break out of loop if there are no more coords to add
- if (args.isEmpty()){
- break;
- }
-
- Double xcoord = args.get(0);
- Double ycoord = args.get(1);
- Double angle = args.get(2);
- Double TEStype = args.get(3);
-
- //add all coordinates to _coordinates ArrayList
- Double pos[] = {xcoord, ycoord, angle, TEStype};
- _coordinates.add(pos);
+ output = new BufferedWriter(fw);
+ _coordinates = getList(inputCoordsFile);
+ ncoords = _coordinates.size();
+ debug = outputType;
+ if(ncoords==0){
+ //quick error check on reading data
+ System.out.println("Is input setup correctly? 0 arguments.");
}
-
- int ncoords = _coordinates.size();
-
+ }
+
+ public boolean getInputStatus(){
+ if(ncoords == 0){
+ return false;
+ }
+ return true;
+ }
+
+ public int printOut() throws IOException{
// before headers, check we want them
- if(outputType==0){
+ if(debug==0){
output.write("BEGIN_RUN\n");
output.write("MM\n");
output.write("SET_DATUM\n");
@@ -132,8 +121,8 @@
fmt1.format("%.6f", x1-(0.5*(m-1))*xDim+j*xDim); // very clever: "extra" pixels go on either side of
fmt2.format("%.6f", y1-(0.5*(n-1))*yDim+k*yDim); // the QET by the 0.5*(m-1) offset here
// will we need to include explicit overlap?
- if(outputType==0) output.write("c:\\Partrtn\\IZipOriginTakePicture_x2_5.RTN,"+fmt1+","+fmt2+",0,0,0,0\n");
- else if(outputType==1) output.write(fmt1+","+fmt2+","+j+" "+k+"\n");
+ if(debug==0) output.write("c:\\Partrtn\\IZipOriginTakePicture_x2_5.RTN,"+fmt1+","+fmt2+",0,0,0,0\n");
+ else if(debug==1) output.write(fmt1+","+fmt2+","+j+" "+k+"\n");
}
}
@@ -153,8 +142,8 @@
Formatter fmt2 = new Formatter();
fmt1.format("%.6f", interps.get(a)[0]);
fmt2.format("%.6f", interps.get(a)[1]);
- if(outputType==0) output.write("c:\\Partrtn\\IZipOriginTakePicture_x2_5.RTN,"+fmt1+","+fmt2+",0,0,0,0\n");
- else if(outputType==1) output.write(fmt1+","+fmt2+",%interp\n");
+ if(debug==0) output.write("c:\\Partrtn\\IZipOriginTakePicture_x2_5.RTN,"+fmt1+","+fmt2+",0,0,0,0\n");
+ else if(debug==1) output.write(fmt1+","+fmt2+",%interp\n");
}
}
}
@@ -162,9 +151,10 @@
}
- if(outputType==0) output.write("END_RUN\n");
+ if(debug==0) output.write("END_RUN\n");
output.close();
+ return 0;
}
private int getXPics(double length){
@@ -183,33 +173,6 @@
return Math.abs(TESlength*Math.sin(angle))+Math.abs(TESwidth*Math.cos(angle));
}
-
- /**
- * Get a list of numbers in a line on the input stream
- *
- * @param tok StreamTokenizer with the next token being the first number
- * @return List of numbers in the current line
- * @throws IOException
- */
- private List<Double> getNumbersInLine(StreamTokenizer tok) throws IOException {
-
- // Create a list of numbers that the tokenizer finds
- List<Double> nums = new ArrayList<Double>();
-
- // Loop looking for either end of line or end of file
- while (tok.nextToken() != StreamTokenizer.TT_EOF) {
- if (tok.ttype == StreamTokenizer.TT_EOL) break;
-
- // Check to make sure that we have a numeric token
- if (tok.ttype != StreamTokenizer.TT_NUMBER) continue;
-
- // Found a number token - add it to the list
- nums.add(tok.nval);
-
- }
- return nums;
- }
-
// the fractional number of pictures that we overlap by in x direction. negative overlap means no overlap,
// and that we're that far apart.
private double getOverlapX(Double[] coords1, Double[] coords2){
@@ -325,7 +288,7 @@
if(overlapX > -1 && overlapY > -1){
- interps.add(getInterpolatedImagePosition(coords1, coords2)); // the case for not so bad failed overlap
+ interps = getInterpolatedImagePosition(coords1, coords2); // the case for not so bad failed overlap
// use the old single overlap technique
}
else{ // we've got a big gap folks
@@ -406,23 +369,34 @@
return interps;
}
+
+ private boolean isLinear(Double coords1[], Double coords2[]){
+
+ Double x1 = 0.001*coords1[0]; //coords are given in um, OGP routine needs them in mm
+ Double y1 = 0.001*coords1[1];
+ Double angle1 = coords1[2];
+ Double x2 = 0.001*coords2[0];
+ Double y2 = 0.001*coords2[1];
+ Double angle2 = coords2[2];
+
+
+ Double anglediff = Math.abs(angle1-angle2);
+ if(anglediff > Math.PI-FLAT_ANGLE_CUT) // if the difference is around pi, then they're linear as well
+ anglediff = Math.abs(anglediff-Math.PI);
+
+ if(anglediff < FLAT_ANGLE_CUT)
+ return true;
+
+ return false;
+ }
- private Double[] getInterpolatedImagePosition(Double coords1[], Double coords2[]){
+ private List<Double[]> getInterpolatedImagePosition(Double coords1[], Double coords2[]){
//returns double that gives x,y image of where we should take an interpolated picture
+ //this is the method for small, simple interps
+ //almost always returns one image: sometimes two at difficult right angles
+
+ List<Double[]> interps = new ArrayList<Double[]>();
- //find cubic function that fits the wiring between adjacent TESs
- //Do this by solving system of linear equations for (A,B,C,D):
- //row 1: A*x1^3 + B*x1^2 + C*x1 + D == y1
- //row 2: A*x2^3 + B*x2^2 + C*x2 + D == y2
- //row 3: derivative of LHS of row 1 wrt x1 == tan(angle1) (=slope at x1)
- //row 4: derivative of LHS of row 2 wrt x2 == tan(angle2) (=slope at x2)
- //It turns out that this method for taking pictures of the wiring between TESs
- // is redundant at the resolutions we're working with--everything is covered by
- // the m by n array of the above code. I'm commenting this section out but
- // leaving it here in case it ever becomes needed.
-
- //It should be noted that this method is not completely accurate for large angles
- // between the TESs--theta ~ pi/2 or so.
//set up input data
@@ -448,91 +422,113 @@
// need a backup method for straight line sections
- if(Math.abs(angle1-angle2)< FLAT_ANGLE_CUT || Math.abs(x1-x2)<0.001*FLAT_XY_CUT || Math.abs(y1-y2)<0.001*FLAT_XY_CUT){
+ //if(Math.abs(angle1-angle2)< FLAT_ANGLE_CUT || Math.abs(x1-x2)<0.001*FLAT_XY_CUT || Math.abs(y1-y2)<0.001*FLAT_XY_CUT){
+ if(isLinear(coords1,coords2)){
// this is a more robust way to test for straight line sections, where other methods fail
// there the easiest thing is just to take the averages: very simple geometry for interpolation
Double[] pos = new Double[2];
pos[0] = (x1+x2)/2;
pos[1] = (y1+y2)/2;
- return pos;
+ interps.add(pos);
+ return interps;
}
else{
- // second: check for large angles. if the angle is near pi/2, use alternate interp.
- //if(Math.abs(angle2-angle1) > Math.PI/4){ // pretty loose cut on the alternate interp...
- // note that this method is vulnerable to having two qet's with same slope
- // probably better to only use it on large angles
// get the extrapolated lines defined by the qet position and angle
Double[] line1 = getLineFromQET(x1, y1, angle1);
Double[] line2 = getLineFromQET(x2, y2, angle2);
// get the point of intersection between them
- return getXYIntersect(line1,line2);
+ Double[] xy = getXYIntersect(line1,line2);
+ interps.add(xy);
+
+ // make a double check that we actually intersect properly with
+ if(!goodOverlapSingle(xy,coords1)){
+ Double[] pos1 = new Double[2];
+ double newx = xy[0] - (line1[0]*xDim)/2;
+ double newy = newx*line1[0] + line1[1];
+ pos1[0]=newx;
+ pos1[1]=newy;
+
+ interps.add(pos1);
+ }
+ if(!goodOverlapSingle(xy,coords2)){
+ Double[] pos2 = new Double[2];
+ double newx = xy[0] + (line2[0]*xDim)/2;
+ double newy = newx*line2[0] + line2[1];
+
+ pos2[0] = newx;
+ pos2[0] = newy;
+ interps.add(pos2);
+ }
+
+ return interps;
}
-
- // we've passed the small jump, small angle check: go to main interpolate code
-//
-// //init matrices
-// BasicMatrix XcoordsMatrix = new BasicMatrix(4,4);
-// BasicMatrix YcoordsVector = new BasicMatrix(4,1);
-// //BasicMatrix functionVector = new BasicMatrix(4,1);
-//
-// //create XcoordsMatrix
-// XcoordsMatrix.setElement(0, 0, Math.pow(x1,3));
-// XcoordsMatrix.setElement(0, 1, Math.pow(x1,2));
-// XcoordsMatrix.setElement(0, 2, x1);
-// XcoordsMatrix.setElement(0, 3, 1);
-// XcoordsMatrix.setElement(1, 0, Math.pow(x2,3));
-// XcoordsMatrix.setElement(1, 1, Math.pow(x2,2));
-// XcoordsMatrix.setElement(1, 2, x2);
-// XcoordsMatrix.setElement(1, 3, 1);
-// XcoordsMatrix.setElement(2, 0, 3*Math.pow(x1,2));
-// XcoordsMatrix.setElement(2, 1, 2*x1);
-// XcoordsMatrix.setElement(2, 2, 1);
-// XcoordsMatrix.setElement(2, 3, 0);
-// XcoordsMatrix.setElement(3, 0, 3*Math.pow(x2,2));
-// XcoordsMatrix.setElement(3, 1, 2*x2);
-// XcoordsMatrix.setElement(3, 2, 1);
-// XcoordsMatrix.setElement(3, 3, 0);
-//
-// YcoordsVector.setElement(0,0, y1);
-// YcoordsVector.setElement(1,0, y2);
-// YcoordsVector.setElement(2,0, Math.tan(angle1));
-// YcoordsVector.setElement(3,0, Math.tan(angle2));
-//
-// Matrix inverse = MatrixOp.inverse(XcoordsMatrix);
-//
-// //find A,B,C,D by inverting XcoordsMatrix
-// Matrix paramVector = MatrixOp.mult(inverse,YcoordsVector);
-//
-// double A = paramVector.e(0,0);
-// double B = paramVector.e(1,0);
-// double C = paramVector.e(2,0);
-// double D = paramVector.e(3,0);
-//
-//
-// Double pos[] = new Double[2];
-// //choose some x between x1 and x2, then calculate y using paramVector
-// if(x1 != x2){
-// double xavg = (x1+x2)/2;
-// double yvalue = A*Math.pow(xavg,3)+B*Math.pow(xavg,2)+C*xavg+D;
-// pos[0] = xavg;
-// pos[1] = yvalue;
-// }
-// else{ //there might be a problem for x1 = x2, so try this
-// double yavg = (y1+y2)/2;
-// pos[0] = x1;
-// pos[1] = yavg;
-// }
-//
-//// Double pos[] = new Double[2];
-//// //explicit average, just take it: very good results compare to cubic
-//// // with 'good' overlap from 3 images in each axis, and very small offset from cubic, safe to use average
-//// pos[0] = (x1+x2)/2;
-//// pos[1] = (y1+y2)/2;
-//
-// return pos;
+ }
+
+ private boolean goodOverlapSingle(Double[] xy, Double[] coords1){
+ Double x = 0.001*xy[0]; //coords are given in um, OGP routine needs them in mm
+ Double y = 0.001*xy[1];
+ Double angle = coords1[2];
+ Double x1 = 0.001*coords1[0];
+ Double y1 = 0.001*coords1[1];
+ Double angle1 = coords1[2];
+
+ double xOverlap = 0;
+ double yOverlap = 0;
+
+ double lx1 = getILengthX(angle1);
+ double ly1 = getILengthY(angle1);
+
+
+ int xPics = 1;
+ int xPics1 = getXPics(lx1);
+
+ double left1 = x1 - xDim*(0.5*xPics1);
+ double left = x - xDim*(0.5*xPics);
+ double right1 = x1 + xDim*0.5*xPics1;
+ double right = x + xDim*0.5*xPics;
+
+
+ int yPics1 = getYPics(ly1);
+ int yPics = 1;
+
+ double top1 = y1+(0.5*(yPics1))*yDim;
+ double top = y+(0.5*(yPics))*yDim;
+ double bot1 = y1-(0.5*(yPics1))*yDim;
+ double bot = y-(0.5*(yPics))*yDim;
+
+
+ if(x1-x==0){
+ xOverlap = 1; // flag that we have good x overlap, don't bother with anything else
+ }
+ else{ // if not simple, check for the real amount of overlap
+ double rightmostLeft = Math.max(left1,left);
+ double leftmostRight = Math.min(right1,right);
+
+ xOverlap = (leftmostRight - rightmostLeft)/xDim;// calculate overlap, normalized by xDim
+ }
+ if (y1-y==0){
+ yOverlap = 1; // same for y now
+ }
+ else{
+ double topmostBottom = Math.max(bot1,bot);
+ double bottommostTop = Math.min(top1, top);
+
+ yOverlap = (bottommostTop - topmostBottom)/yDim;
+ }
+
+ if(Math.max(yOverlap, xOverlap) > OVERLAP_FRAC-0.5 && Math.min(yOverlap,xOverlap) > 0){
+ return true;
+ }
+ else{
+
+ System.out.println("poor overlap on single, interping! yOverlap is " + yOverlap + " xOverlap is " + xOverlap);
+
+ return false;
+ }
+
}
private boolean goodOverlap(Double[] coords1, Double[] coords2){
@@ -576,10 +572,10 @@
int yPics1 = getYPics(ly1);
int yPics2 = getYPics(ly2);
- double top1 = y1+(0.5*(yPics1-1))*yDim;
- double top2 = y2+(0.5*(yPics2-1))*yDim;
- double bot1 = y1-(0.5*(yPics1-1))*yDim;
- double bot2 = y2-(0.5*(yPics2-1))*yDim;
+ double top1 = y1+(0.5*(yPics1))*yDim;
+ double top2 = y2+(0.5*(yPics2))*yDim;
+ double bot1 = y1-(0.5*(yPics1))*yDim;
+ double bot2 = y2-(0.5*(yPics2))*yDim;
if(x1-x2==0){
xOverlap = 1; // flag that we have good x overlap, don't bother with anything else
@@ -605,11 +601,15 @@
// if lots of overlap in one direction, and > 0 overlap in another direction, we can be pretty sure
// we don't need overlap. but otherwise, let's say bad overlap, take another picture.
- if(Math.max(yOverlap, xOverlap) > OVERLAP_FRAC && Math.min(yOverlap,xOverlap) > 0)
+ if(Math.max(yOverlap, xOverlap) > OVERLAP_FRAC && Math.min(yOverlap,xOverlap) > 0){
+ System.out.println("good overlap, skipping!");
+ System.out.println("yOverlap is " + yOverlap);
+ System.out.println("xOverlap is " + xOverlap);
return true;
+ }
else{
- if(Math.min(yOverlap,xOverlap)<0){
- //System.out.println("no overlap!");
+ if(Math.min(yOverlap,xOverlap)>0){
+ System.out.println("small overlap, interping! yOverlap is " + yOverlap + " xOverlap is " + xOverlap);
}
return false;
}
@@ -649,45 +649,6 @@
return xy;
}
-
- private static double FLAT_ANGLE_CUT = 0.1;
- private static double FLAT_XY_CUT = 100;
-
- // returns 0 if not straight
- // returns -1 if horizontal
- // returns 1 if vertical
- private int isStraight(Double[] coords1, Double[] coords2){
- Double x1 = coords1[0];
- Double x2 = coords2[0];
- Double y1 = coords1[1];
- Double y2 = coords2[1];
- Double angle1 = coords1[2];
- Double angle2 = coords2[2];
-
- //double piremain1 = Math.abs(angle1)%Math.PI;
- //double piremain2 = Math.abs(angle2)%Math.PI;
-
- //if((piremain1 < FLAT_ANGLE_CUT || piremain1 > Math.PI-FLAT_ANGLE_CUT)
- // && (piremain2 < FLAT_ANGLE_CUT || piremain2 > Math.PI-FLAT_ANGLE_CUT) ){
- //if(Math.abs(Math.abs(angle1)-Math.PI) < FLAT_ANGLE_CUT && Math.abs(Math.abs(angle2)-Math.PI) < FLAT_ANGLE_CUT ){
- if((Math.abs(Math.abs(angle1)-Math.PI) < FLAT_ANGLE_CUT || Math.abs(angle1) < FLAT_ANGLE_CUT)
- && (Math.abs(Math.abs(angle2)-Math.PI) < FLAT_ANGLE_CUT || Math.abs(angle1) < FLAT_ANGLE_CUT) ){
- //both are horizontal in this case: check that they're in the same line now
- if(Math.abs(y1-y2) < FLAT_XY_CUT){
- // they're in the same line, and they're horizontal
- return -1;
- }
- }
- //else if(((Math.abs(angle1)%(Math.PI/2)) < FLAT_ANGLE_CUT ) && (Math.abs(angle1)%(Math.PI) > FLAT_ANGLE_CUT )
- // && ((Math.abs(angle2)%(Math.PI/2)) < FLAT_ANGLE_CUT) && (Math.abs(angle2)%(Math.PI) > FLAT_ANGLE_CUT )){
- else if(Math.abs(Math.abs(angle1)-Math.PI/2) < FLAT_ANGLE_CUT && Math.abs(Math.abs(angle2)-Math.PI/2) < FLAT_ANGLE_CUT){
- // both are vertical.
- if(Math.abs(x1-x2) < FLAT_XY_CUT){
- return 1;
- }
- }
-
- return 0;
- }
+
}
CDMS/src/CDMS/kscheck
diff -u -r1.4 -r1.5
--- SortCoordsFile.java 31 Jan 2011 04:11:11 -0000 1.4
+++ SortCoordsFile.java 5 Feb 2011 20:45:38 -0000 1.5
@@ -22,7 +22,7 @@
* Usage: construct, sort, print. sort kills the input'ed coordinate list: create a new object
* to sort your list again. bool getInputStatus tells us if there is a list ready to be sorted.
*/
-public class SortCoordsFile {
+public class SortCoordsFile extends MapUtil{
private static double RIGHT_CUTOFF = 500;
private static double BIG_CUTOFF = 2000;
@@ -33,6 +33,7 @@
private List<Double[]> nextCoords;
FileWriter fw;
FileReader fr;
+ private int debug;
/**
* Constructor: takes in inputCoordsFile and parses to a list.
@@ -41,46 +42,14 @@
* @throws FileNotFoundException
* @throws IOException
*/
- public SortCoordsFile(String inputCoordsFile, String outputSortedFile) throws FileNotFoundException, IOException {
+ public SortCoordsFile(String inputCoordsFile, String outputSortedFile, int outputType) throws FileNotFoundException, IOException {
- // Open the autorun file and setup a StreamTokenizer for a space delimited list
- fr = new FileReader(inputCoordsFile);
fw = new FileWriter(outputSortedFile);
+ debug = outputType;
- StreamTokenizer tok = new StreamTokenizer(fr);
- tok.resetSyntax();
- tok.wordChars(33, 126);//normal text are words
- tok.parseNumbers(); //set numbers to be marked as numeric so we can flag them
- tok.whitespaceChars(0, 32);//commands and spaces are whitespace
- tok.eolIsSignificant(true);
- tok.commentChar('%');
-
- _coordinates = new ArrayList<Double[]>();
- List<Double> args = getNumbersInLine(tok);
+ _coordinates = getList(inputCoordsFile);
- // Loop over the input coordinate file entries
- while (args!=null) {
- System.out.println("in loop");
- //no coordinates: means we have a blank line. (or a comment line or something similar)
- //continue on till we reach end of file or a real line
- if (!args.isEmpty()){
-
- Double xcoord = args.get(0);
- Double ycoord = args.get(1);
- Double angle = args.get(2);
- Double TEStype = args.get(3);
-
- //add all coordinates to _coordinates ArrayList
- Double pos[] = {xcoord, ycoord, angle, TEStype};
- _coordinates.add(pos);
- System.out.print(pos[0]);
- }
- else System.out.println("blank line!");
- args = getNumbersInLine(tok); // get the next set of args: if it's null, we're going to break out
- // if it's blank, we'll just continue on
- }
- System.out.println("out of loop?");
ncoords = _coordinates.size();
if(ncoords==0){
@@ -98,7 +67,7 @@
}
public void printOut() throws IOException{
- printOut(0);
+ printOut(debug);
}
public void printOut(int flag) throws IOException{
@@ -480,46 +449,6 @@
return removestatus;
}
- private static double FLAT_ANGLE_CUT = 0.1;
- private static double FLAT_XY_CUT = 100;
-
- // returns 0 if not straight
- // returns -1 if horizontal
- // returns 1 if vertical
- private int isStraight(Double[] coords1, Double[] coords2){
- Double x1 = coords1[0];
- Double x2 = coords2[0];
- Double y1 = coords1[1];
- Double y2 = coords2[1];
- Double angle1 = coords1[2];
- Double angle2 = coords2[2];
-
- //double piremain1 = Math.abs(angle1)%Math.PI;
- //double piremain2 = Math.abs(angle2)%Math.PI;
-
- //if((piremain1 < FLAT_ANGLE_CUT || piremain1 > Math.PI-FLAT_ANGLE_CUT)
- // && (piremain2 < FLAT_ANGLE_CUT || piremain2 > Math.PI-FLAT_ANGLE_CUT) ){
- //if(Math.abs(Math.abs(angle1)-Math.PI) < FLAT_ANGLE_CUT && Math.abs(Math.abs(angle2)-Math.PI) < FLAT_ANGLE_CUT ){
- if((Math.abs(Math.abs(angle1)-Math.PI) < FLAT_ANGLE_CUT || Math.abs(angle1) < FLAT_ANGLE_CUT)
- && (Math.abs(Math.abs(angle2)-Math.PI) < FLAT_ANGLE_CUT || Math.abs(angle1) < FLAT_ANGLE_CUT) ){
- //both are horizontal in this case: check that they're in the same line now
- if(Math.abs(y1-y2) < FLAT_XY_CUT){
- // they're in the same line, and they're horizontal
- return -1;
- }
- }
- //else if(((Math.abs(angle1)%(Math.PI/2)) < FLAT_ANGLE_CUT ) && (Math.abs(angle1)%(Math.PI) > FLAT_ANGLE_CUT )
- // && ((Math.abs(angle2)%(Math.PI/2)) < FLAT_ANGLE_CUT) && (Math.abs(angle2)%(Math.PI) > FLAT_ANGLE_CUT )){
- else if(Math.abs(Math.abs(angle1)-Math.PI/2) < FLAT_ANGLE_CUT && Math.abs(Math.abs(angle2)-Math.PI/2) < FLAT_ANGLE_CUT){
- // both are vertical.
- if(Math.abs(x1-x2) < FLAT_XY_CUT){
- return 1;
- }
- }
-
- return 0;
- }
-
public List<Double[]> getImageCoordinates() {
return _coordinates;
}
@@ -528,40 +457,6 @@
return _coordinates.get(i);
}
- /**
- * Get a list of numbers in a line on the input stream
- *
- * @param tok StreamTokenizer with the next token being the first number
- * @return List of numbers in the current line
- * @throws IOException
- */
- private List<Double> getNumbersInLine(StreamTokenizer tok){
- try{
- // Create a list of numbers that the tokenizer finds
- List<Double> nums = new ArrayList<Double>();
-
- // Loop looking for either end of line or end of file
- while (tok.nextToken() != StreamTokenizer.TT_EOL) {
- if(tok.ttype==StreamTokenizer.TT_EOF) return null; // reached EOF: get out of here!
- // note we assume this is not on a line with data
-
- //if (tok.ttype == StreamTokenizer.TT_EOL) break;
-
- // Check to make sure that we have a numeric token
- if (tok.ttype != StreamTokenizer.TT_NUMBER) continue;
-
- // Found a number token - add it to the list
- nums.add(tok.nval);
-
- }
- //if(nums.size()==0 && tok.ttype==StreamTokenizer.TT_EOF) return null;
- return nums;
- }
- catch(IOException exception){
- return null;
- }
- }
-
}
\ No newline at end of file