### Question:
RayUtil { public static boolean isPointOnRay(Point2d point, Ray2d ray, double epsilon) { Vector2d rayDirection = new Vector2d(ray.U); rayDirection.normalize(); Vector2d pointVector = new Vector2d(point); pointVector.sub(ray.A); double dot = rayDirection.dot(pointVector); if (dot < epsilon) { return false; } double x = rayDirection.x; rayDirection.x = rayDirection.y; rayDirection.y = -x; dot = rayDirection.dot(pointVector); return -epsilon < dot && dot < epsilon; } private  RayUtil(); static boolean isPointOnRay(Point2d point, Ray2d ray, double epsilon); static IntersectPoints intersectRays2d(Ray2d r1, Ray2d r2);  }### Answer:
@Test public void testIsPointOnRay_1() { Point2d point = new Point2d(-2.0, 2.0); Ray2d ray = new Ray2d(new Point2d(-1.0, 1.0), new Vector2d(-1.0, 1.0)); assertTrue(RayUtil.isPointOnRay(point, ray, 0.0000001)); }
@Test public void testIsPointOnRay_2() { Point2d point = new Point2d(-2.1, 2.0); Ray2d ray = new Ray2d(new Point2d(-1.0, 1.0), new Vector2d(-1.0, 1.0)); assertFalse(RayUtil.isPointOnRay(point, ray, 0.0000001)); }
@Test public void testIsPointOnRay_3() { Point2d point = new Point2d(2.0, -2.0); Ray2d ray = new Ray2d(new Point2d(-1.0, 1.0), new Vector2d(-1.0, 1.0)); assertFalse(RayUtil.isPointOnRay(point, ray, 0.0000001)); }