Plane { public double distanceToPoint(Vec3 point) { return this.dot(point); } Plane();  Plane(double x, double y, double z, double distance);  Plane(Plane plane); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); double distanceToPoint(Vec3 point); Plane set(double x, double y, double z, double distance); Plane set(Plane plane); Plane transformByMatrix(Matrix4 matrix); double dot(Vec3 vector); boolean intersectsSegment(Vec3 endPoint1, Vec3 endPoint2); int onSameSide(Vec3 pointA, Vec3 pointB); Vec3[] clip(Vec3 pointA, Vec3 pointB);  }
@Test public void testDistanceToPoint() throws Exception { Vec3 normal = new Vec3(3, 4, 5).normalize(); double distance = 10; Plane plane = new Plane(normal.x, normal.y, normal.z, distance); Vec3 point = new Vec3(normal).negate().multiply(distance); Vec3 origin = new Vec3(0, 0, 0); double distanceToOrigin = plane.distanceToPoint(origin); double distanceToPoint = plane.distanceToPoint(point); assertEquals("distance to origin", distance, distanceToOrigin, 0); assertEquals("distance to point on plane", 0, distanceToPoint, 0); }