/** Construct the most accurate normalized plane through an x-z point and including the Y axis. * If none of the points can determine the plane, return null. * @param planePoints is a set of points to choose from. The best one for constructing the most precise plane is picked. * @return the plane */ public static Plane constructNormalizedYPlane(final Vector... planePoints) { // Pick the best one (with the greatest x-z distance) double bestDistance = 0.0; Vector bestPoint = null; for (final Vector point : planePoints) { final double pointDist = point.x * point.x + point.z * point.z; if (pointDist > bestDistance) { bestDistance = pointDist; bestPoint = point; } } return constructNormalizedYPlane(bestPoint.x, bestPoint.z, 0.0); }