private ArrayList<Point2d> getAllIntersections() { ArrayList<Point2d> intersections = new ArrayList<Point2d>(); ArrayList<Line2d> linesCopy = new ArrayList<Line2d>(lines); for (Line2d line : lines) { int count = 0; linesCopy.remove(line); for (Line2d line2d : linesCopy) { count++; Point2d intersection = line.intersectionWith(line2d); if (intersection != null) { intersections.add(intersection); } } } return intersections; } }
@Override public FramePoint2d[] intersectionWith(FrameConvexPolygon2d convexPolygon) { checkReferenceFrameMatch(convexPolygon); Point2d[] intersection = this.line.intersectionWith(convexPolygon.convexPolygon); if (intersection == null) { return null; } FramePoint2d[] ret = new FramePoint2d[intersection.length]; for (int i = 0; i < intersection.length; i++) { ret[i] = new FramePoint2d(convexPolygon.referenceFrame, intersection[i]); } return ret; }
@Override public FramePoint2d intersectionWith(FrameLineSegment2d lineSegment) { checkReferenceFrameMatch(lineSegment); Point2d intersection = this.line.intersectionWith(lineSegment.lineSegment); return new FramePoint2d(lineSegment.getReferenceFrame(), intersection); }
@Override public FramePoint2d intersectionWith(FrameLine2d secondLine) { checkReferenceFrameMatch(secondLine); Point2d intersection = this.line.intersectionWith(secondLine.line); return new FramePoint2d(secondLine.getReferenceFrame(), intersection); }
public void paint(Graphics graphics) { Color originalGraphicsColor = graphics.getColor(); graphics.setColor(Color.red); Graphics2D g2d = (Graphics2D) graphics; Stroke originalStroke = g2d.getStroke(); g2d.setStroke(new BasicStroke(lineThickness)); Line2d xMin = new Line2d(new Point2d(0, 0), new Vector2d(1.0, 0.0)); Line2d xMax = new Line2d(new Point2d(0, imageHeight), new Vector2d(1.0, 0.0)); for (Line2d line : lines) { Point2d p1 = line.intersectionWith(xMin); Point2d p2 = line.intersectionWith(xMax); graphics.drawLine((int) p1.getX(), (int)p1.getY(), (int)p2.getX(), (int) p2.getY()); } graphics.setColor(originalGraphicsColor); g2d.setStroke(originalStroke); } }
public void getIntersectionWithLine(FrameLine2d line, FramePoint2d intersectionToPack) { checkReferenceFrameMatch(line); checkReferenceFrameMatch(intersectionToPack); this.line.intersectionWith(line.getLine2d(), intersectionToPack.getPoint()); }
double leftX = leftEdgeOfRoad.intersectionWith(axis).getX(); double rightX = rightEdgeOfRoad.intersectionWith(axis).getX(); double range = rightX - leftX; double midPoint = leftX + (range / 2.0);
public Line2d interiorBisector(Line2d secondLine) { Point2d pointOnLine = intersectionWith(secondLine); if (pointOnLine == null) { double distanceBetweenLines = secondLine.distance(point); double epsilon = 1E-7; boolean sameLines = distanceBetweenLines < epsilon; if (sameLines) { return new Line2d(this); } else { return null; } } Vector2d directionVector = new Vector2d(normalizedVector); directionVector.add(secondLine.normalizedVector); return new Line2d(pointOnLine, directionVector); }
double leftXInPixels = leftEdgeOfRoad.intersectionWith(axis).getX(); double rightXInPixels = rightEdgeOfRoad.intersectionWith(axis).getX();
if (intersection == null) throw new RuntimeException("intersection == null!"); boolean foundIntersection = ray.intersectionWith(previousRayToCheck, intersection); foundIntersection = ray.intersectionWith(evenMorePreviousRayToCheck, intersection); if (!foundIntersection)
tempIntersectFrameLineTwo.get().projectOntoXYPlane(tempIntersectLine2dTwo.get()); tempIntersectLine2dOne.get().intersectionWith(tempIntersectLine2dTwo.get(), intersectionToPack.getPoint());