@Override
    public double calcNormalizedEdgeDistance3D(double ry, double rx, double rz,
                                               double ay, double ax, double az,
                                               double by, double bx, double bz) {
        double dx = bx - ax;
        double dy = by - ay;
        double dz = bz - az;

        double norm = dx * dx + dy * dy + dz * dz;
        double factor = ((rx - ax) * dx + (ry - ay) * dy + (rz - az) * dz) / norm;
        if (Double.isNaN(factor)) factor = 0;

        // x,y,z is projection of r onto segment a-b
        double cx = ax + factor * dx;
        double cy = ay + factor * dy;
        double cz = az + factor * dz;

        double rdx = cx - rx;
        double rdy = cy - ry;
        double rdz = cz - rz;

        return rdx * rdx + rdy * rdy + rdz * rdz;
    }
@Test
    public void testCalcNormalizedEdgeDistance3dStartEndSame() {
        DistanceCalcEuclidean distanceCalc = new DistanceCalcEuclidean();
        double distance = distanceCalc.calcNormalizedEdgeDistance3D(0, 3, 4, 0, 0, 0, 0, 0, 0);
        assertEquals(25, distance, 0);
    }