### Question:
Line2d { public Vector2d getIntersection(Ray2d ray, boolean allowNegative) { double dist = getDistance(ray); if (Double.isNaN(dist) || dist < 0. && !allowNegative) { return null; } return ray.getPosition().add(ray.getDirection().multiply(dist)); } Line2d(Vector2d point, Vector2d normal); double distance(Vector2d pos); double getDistance(Ray2d ray); Vector2d getIntersection(Ray2d ray, boolean allowNegative); Vector2d getIntersection(Vector2d ptA, Vector2d ptB); Vector2d getNormal(); Vector2d getPoint(); List<? extends Vector2d> getSegmentIntersection(Vector2d ptA, Vector2d ptB); boolean hasIntersection(Vector2d ptA, Vector2d ptB); boolean isInFront(Vector2d position, double distance); boolean onSameSide(Vector2d ptA, Vector2d ptB); Vector2d project(Vector2d pos);  }### Answer:
@Test public void testIntersectionRay2d() { Line2d line = new Line2d(new Vector2d(0., 0.), new Vector2d(0., 1.)); Ray2d parallelRay = new Ray2d(new Vector2d(0., 1.), new Vector2d(2., 0.)); Assert.assertNull(line.getIntersection(parallelRay, true)); Ray2d ray = new Ray2d(new Vector2d(0., 1.), new Vector2d(4., -1.)); Assert.assertEquals(new Vector2d(4., 0.), line.getIntersection(ray, true)); }