// normal vector of the plane is the same everywhere public double findIntersection(Ray r) { Vector dir = r.direction; double a = dir.dotProduct(norm); if (a == 0) { // no intersection return(-99); } else { Vector originToDir = r.orgin + r.direction.norm().ScalarMultiply(distance).negate(); double b = originToDir.norm().dotProduct(); return(b); } }