code: public static double distance3d( Coordinate c1, Coordinate c2, GeodeticCalculator geodeticCalculator ) {
          if (Double.isNaN(c1.z) || Double.isNaN(c2.z)) {
              throw new IllegalArgumentException("Missing elevation information in the supplied coordinates.");
          }
          double deltaElev = Math.abs(c1.z - c2.z);
          double projectedDistance;
          if (geodeticCalculator != null) {
              geodeticCalculator.setStartingGeographicPoint(c1.x, c1.y);
              geodeticCalculator.setDestinationGeographicPoint(c2.x, c2.y);
              projectedDistance = geodeticCalculator.getOrthodromicDistance();
          } else {
              projectedDistance = c1.distance(c2);
          }
  
          double distance = NumericsUtilities.pythagoras(projectedDistance, deltaElev);
          return distance;
      }
docs: Calculates the 3d distance between two coordinates that have an elevation information.
  
  <p>Note that the {@link Coordinate#distance(Coordinate)} method does only 2d.
  
  @param c1 coordinate 1.
  @param c2 coordinate 2.
  @param geodeticCalculator If supplied it will be used for planar distance calculation.
  @return the distance considering also elevation.