coords[0], coords[1]); if (line.intersectsLine(l)) { return getLinesIntersection(line, l);
case PathIterator.SEG_LINETO : { final Line2D.Double currentLine = new Line2D.Double(lastCoords[0], lastCoords[1], coords[0], coords[1]); if(currentLine.intersectsLine(losLine)) { hexsides.add(hexside); if(currentLine.intersectsLine(losLine)) { hexsides.add(hexside);
private boolean checkSelected(int[] ar, double[] yPos, double x1, double x2, double y1, double y2) { final int dim = proj.getVisibleDimensions(); if(ar[0] < 0) { ar[0] = 0; } if(ar[1] >= dim) { ar[1] = dim - 1; } for(int i = ar[0] + 1; i <= ar[1] - 1; i++) { if(yPos[i] <= y1 && yPos[i] >= y2) { return true; } } Line2D.Double idline1 = new Line2D.Double(getVisibleAxisX(ar[0]), yPos[ar[0]], getVisibleAxisX(ar[0] + 1), yPos[ar[0] + 1]); Line2D.Double idline2 = new Line2D.Double(getVisibleAxisX(ar[1] - 1), yPos[ar[1] - 1], getVisibleAxisX(ar[1]), yPos[ar[1]]); Line2D.Double rectline1 = new Line2D.Double(x2, y1, x1, y1); Line2D.Double rectline2 = new Line2D.Double(x2, y1, x2, y2); Line2D.Double rectline3 = new Line2D.Double(x2, y2, x1, y2); if(idline1.intersectsLine(rectline1) || idline1.intersectsLine(rectline2) || idline1.intersectsLine(rectline3)) { return true; } Line2D.Double rectline4 = new Line2D.Double(x1, y1, x1, y2); return idline2.intersectsLine(rectline1) || idline2.intersectsLine(rectline4) || idline2.intersectsLine(rectline3); }
private static boolean intersectsLineStrictInternal(Line2D.Double l1, Line2D.Double l2) { if (l1.intersectsLine(l2) == false) { return false; assert l1.intersectsLine(l2);
/** * Checks if two bonds cross each other. * *@param bond1 Description of the Parameter *@param bond2 Description of the Parameter *@return Description of the Return Value */ public boolean areIntersected(IBond bond1, IBond bond2) { double x1 = 0, x2 = 0, x3 = 0, x4 = 0; double y1 = 0, y2 = 0, y3 = 0, y4 = 0; //Point2D.Double p1 = null, p2 = null, p3 = null, p4 = null; x1 = bond1.getBegin().getPoint2d().x; x2 = bond1.getEnd().getPoint2d().x; x3 = bond2.getBegin().getPoint2d().x; x4 = bond2.getEnd().getPoint2d().x; y1 = bond1.getBegin().getPoint2d().y; y2 = bond1.getEnd().getPoint2d().y; y3 = bond2.getBegin().getPoint2d().y; y4 = bond2.getEnd().getPoint2d().y; Line2D.Double line1 = new Line2D.Double(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2)); Line2D.Double line2 = new Line2D.Double(new Point2D.Double(x3, y3), new Point2D.Double(x4, y4)); if (line1.intersectsLine(line2)) { logger.debug("Two intersecting bonds detected."); return true; } return false; }
/** * Checks if two bonds cross each other. * *@param bond1 Description of the Parameter *@param bond2 Description of the Parameter *@return Description of the Return Value */ public boolean areIntersected(IBond bond1, IBond bond2) { double x1 = 0, x2 = 0, x3 = 0, x4 = 0; double y1 = 0, y2 = 0, y3 = 0, y4 = 0; //Point2D.Double p1 = null, p2 = null, p3 = null, p4 = null; x1 = bond1.getBegin().getPoint2d().x; x2 = bond1.getEnd().getPoint2d().x; x3 = bond2.getBegin().getPoint2d().x; x4 = bond2.getEnd().getPoint2d().x; y1 = bond1.getBegin().getPoint2d().y; y2 = bond1.getEnd().getPoint2d().y; y3 = bond2.getBegin().getPoint2d().y; y4 = bond2.getEnd().getPoint2d().y; Line2D.Double line1 = new Line2D.Double(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2)); Line2D.Double line2 = new Line2D.Double(new Point2D.Double(x3, y3), new Point2D.Double(x4, y4)); if (line1.intersectsLine(line2)) { logger.debug("Two intersecting bonds detected."); return true; } return false; }
/** * Line intersection. * * @param gc1Start * the gc1 start * @param gc1End * the gc1 end * @param gc2Start * the gc2 start * @param gc2End * the gc2 end * @return true, if successful */ public static boolean lineIntersection(final GeoCoordinates gc1Start, final GeoCoordinates gc1End, final GeoCoordinates gc2Start, final GeoCoordinates gc2End) { Line2D.Double line1 = new Line2D.Double(gc1Start.getLongitudeDeg(), gc1Start.getLatitudeDeg(), gc1End.getLongitudeDeg(), gc1End.getLatitudeDeg()); Line2D.Double line2 = new Line2D.Double(gc2Start.getLongitudeDeg(), gc2Start.getLatitudeDeg(), gc2End.getLongitudeDeg(), gc2End.getLatitudeDeg()); return line1.intersectsLine(line2); }
private boolean checkSelected(int[] ar, double[] yPos, double x1, double x2, double y1, double y2) { final int dim = proj.getVisibleDimensions(); if(ar[0] < 0) { ar[0] = 0; } if(ar[1] >= dim) { ar[1] = dim - 1; } for(int i = ar[0] + 1; i <= ar[1] - 1; i++) { if(yPos[i] <= y1 && yPos[i] >= y2) { return true; } } Line2D.Double idline1 = new Line2D.Double(getVisibleAxisX(ar[0]), yPos[ar[0]], getVisibleAxisX(ar[0] + 1), yPos[ar[0] + 1]); Line2D.Double idline2 = new Line2D.Double(getVisibleAxisX(ar[1] - 1), yPos[ar[1] - 1], getVisibleAxisX(ar[1]), yPos[ar[1]]); Line2D.Double rectline1 = new Line2D.Double(x2, y1, x1, y1); Line2D.Double rectline2 = new Line2D.Double(x2, y1, x2, y2); Line2D.Double rectline3 = new Line2D.Double(x2, y2, x1, y2); if(idline1.intersectsLine(rectline1) || idline1.intersectsLine(rectline2) || idline1.intersectsLine(rectline3)) { return true; } Line2D.Double rectline4 = new Line2D.Double(x1, y1, x1, y2); if(idline2.intersectsLine(rectline1) || idline2.intersectsLine(rectline4) || idline2.intersectsLine(rectline3)) { return true; } return false; }
Line2D.Double firstLine = new Line2D.Double(0.0, 0.0, 1.0, 1.0); Line2D.Double secondLine = new Line2D.Double(0.5, 0.0, 0.5, 1.0); boolean intersectionOccurs = firstLine.intersectsLine(secondLine);
private boolean intersects(MyCurve other) { for (Line2D.Double l1 : this.linesForInters) { for (Line2D.Double l2 : other.linesForInters) { if (l1.intersectsLine(l2)) { return true; } } } return false; }
private static boolean intersectsLineStrictInternal(Line2D.Double l1, Line2D.Double l2) { if (l1.intersectsLine(l2) == false) { return false; assert l1.intersectsLine(l2);
private boolean intersects(MyCurve other) { for (Line2D.Double l1 : this.linesForInters) { for (Line2D.Double l2 : other.linesForInters) { if (l1.intersectsLine(l2)) { return true; } } } return false; }