public static Vector3D intersection()

in commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java [408:442]


    public static Vector3D intersection(final Plane plane1, final Plane plane2, final Plane plane3) {

        // coefficients of the three planes linear equations
        final double a1 = plane1.normal.getX();
        final double b1 = plane1.normal.getY();
        final double c1 = plane1.normal.getZ();
        final double d1 = plane1.originOffset;

        final double a2 = plane2.normal.getX();
        final double b2 = plane2.normal.getY();
        final double c2 = plane2.normal.getZ();
        final double d2 = plane2.originOffset;

        final double a3 = plane3.normal.getX();
        final double b3 = plane3.normal.getY();
        final double c3 = plane3.normal.getZ();
        final double d3 = plane3.originOffset;

        // direct Cramer resolution of the linear system
        // (this is still feasible for a 3x3 system)
        final double a23 = (b2 * c3) - (b3 * c2);
        final double b23 = (c2 * a3) - (c3 * a2);
        final double c23 = (a2 * b3) - (a3 * b2);
        final double determinant = (a1 * a23) + (b1 * b23) + (c1 * c23);

        // use the precision context of the first plane to determine equality
        if (plane1.getPrecision().eqZero(determinant)) {
            return null;
        }

        final double r = 1.0 / determinant;
        return Vector3D.of((-a23 * d1 - (c1 * b3 - c3 * b1) * d2 - (c2 * b1 - c1 * b2) * d3) * r,
                (-b23 * d1 - (c3 * a1 - c1 * a3) * d2 - (c1 * a2 - c2 * a1) * d3) * r,
                (-c23 * d1 - (b1 * a3 - b3 * a1) * d2 - (b2 * a1 - b1 * a2) * d3) * r);
    }