code: public double calculateDistance(S individual, double[] lambda,
                                    double[] z_, double[] nz_) {
  
      double scale;
      double distance;
  
      double[] vecInd = new double[problem.getNumberOfObjectives()];
      double[] vecProj = new double[problem.getNumberOfObjectives()];
  
      // normalize the weight vector (line segment)
      double nd = norm_vector(lambda);
      for (int i = 0; i < problem.getNumberOfObjectives(); i++) {
        lambda[i] = lambda[i] / nd;
      }
  
      // vecInd has been normalized to the range [0,1]
      for (int i = 0; i < problem.getNumberOfObjectives(); i++) {
        vecInd[i] = (individual.getObjective(i) - z_[i]) / (nz_[i] - z_[i]);
      }
  
      scale = innerproduct(vecInd, lambda);
      for (int i = 0; i < problem.getNumberOfObjectives(); i++) {
        vecProj[i] = vecInd[i] - scale * lambda[i];
      }
  
      distance = norm_vector(vecProj);
  
      return distance;
    }
docs: Calculate the perpendicular distance between the solution and reference line