Пример #1
0
 /* Check hashmap for lines that are equivalent. Note that we need to check one epsilon above and below the actual slope
  * since we're defining two lines as equivalent if they're within an epsilon of each other.
  */
 public static int countEquivalentLines(HashMap<Double, ArrayList<Line>> linesBySlope, Line line) {
   double key = Line.floorToNearestEpsilon(line.slope);
   int count = countEquivalentLines(linesBySlope.get(key), line);
   count += countEquivalentLines(linesBySlope.get(key - Line.epsilon), line);
   count += countEquivalentLines(linesBySlope.get(key + Line.epsilon), line);
   return count;
 }
Пример #2
0
 /* insert line into hashmap */
 public static void insertLine(HashMap<Double, ArrayList<Line>> linesBySlope, Line line) {
   ArrayList<Line> lines = null;
   double key = Line.floorToNearestEpsilon(line.slope);
   if (!linesBySlope.containsKey(key)) {
     lines = new ArrayList<Line>();
     linesBySlope.put(key, lines);
   } else {
     lines = linesBySlope.get(key);
   }
   lines.add(line);
 }