// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java
// public class VisualLog {
// 
//     //private static Activity activity;
//     private static String nullstring = "null";
//     //private static TextView txtDebugLog;
// 
//     static private String checkNull(String msg) {
//         return msg == null ? nullstring : msg;
//     }
// 
//     static public void d(String tag, String msg) {
//         Log.d(tag, checkNull(msg));
//         printToDebug(tag, checkNull(msg));
//     }
// 
//     static public void e(String msg) {
//         e(new Exception().getStackTrace()[1].getClassName(), msg);
//     }
// 
//     static public void d(String msg) {
//         d(new Exception().getStackTrace()[1].getClassName(), msg);
//     }
// 
//     static public void d(String tag, String msg, Throwable tr) {
//         Log.e(tag, checkNull(msg), tr);
//         printToDebug(tag, checkNull(msg));
//         printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr));
//     }
// 
//     static public void w(String tag, String msg) {
//         Log.w(tag, checkNull(msg));
//         printToDebug(tag, checkNull(msg));
//     }
// 
//     static public void w(String msg) {
//         w(new Exception().getStackTrace()[1].getClassName(), msg);
//     }
// 
//     static public void e(String tag, String msg) {
//         Log.e(tag, checkNull(msg));
//         printToDebug(tag, checkNull(msg));
//     }
// 
//     static public void e(String tag, String msg, Throwable tr) {
//         Log.e(tag, checkNull(msg), tr);
//         printToDebug(tag, checkNull(msg));
//         printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr));
//     }
// 
//     static public void e(String msg, Throwable tr) {
//         e(new Exception().getStackTrace()[1].getClassName(), msg, tr);
//     }
// 
//     static public void e(Throwable tr) {
//         VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr);
//     }
// 
//     static public void i(String tag, String msg) {
//         Log.i(tag, checkNull(msg));
//         printToDebug(tag, checkNull(msg));
//     }
// 
//     static public void i(String msg) {
//         i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg));
// 
//     }
// 
//     static private void printToDebug(final String t, final String s) {
//         /*
//         activity.runOnUiThread(new Runnable() {
//             @Override
//             public void run() {
//                 if (txtDebugLog != null) {
//                     txtDebugLog.append(t + " " + s + "\n");
//                 }
//             }
//         });
//         */
//     }
// 
//     public static void setActivity(Activity activity) {
//         //VisualLog.activity = activity;
//         //VisualLog.nullstring = activity.getString(R.string.NULL);
//     }
// 
//     public static void setDebugLogTextView(TextView txtDebugLog) {
//         //VisualLog.txtDebugLog = txtDebugLog;
//     }
// }


import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.DecompositionSolver;
import org.apache.commons.math3.linear.EigenDecomposition;
import org.apache.commons.math3.linear.MatrixUtils;
import org.apache.commons.math3.linear.RealMatrix;
import org.apache.commons.math3.linear.RealVector;
import org.apache.commons.math3.linear.SingularValueDecomposition;
import org.librepilot.lp2go.VisualLog;
import java.util.Arrays;
import java.util.List;

        // Get the eigenvalues and eigenvectors.
        EigenDecomposition ed = new EigenDecomposition(subr, 0);
        evals = ed.getRealEigenvalues();
        evecs = ed.getEigenvector(0);
        evecs1 = ed.getEigenvector(1);
        evecs2 = ed.getEigenvector(2);

        // Find the radii of the ellipsoid.
        radii = findRadii(evals);
        return true;
    }

    /**
     * Solve the polynomial expression Ax^2 + By^2 + Cz^2 + 2Dxy + 2Exz + 2Fyz +
     * 2Gx + 2Hy + 2Iz from the provided points.
     *
     * @param points the points that will be fit to the polynomial expression.
     * @return the solution vector to the polynomial expression.
     */
    private RealVector solveSystem(List<? extends ThreeSpacePoint> points) {
        // determine the number of points
        int numPoints = points.size();

        // the design matrix
        // size: numPoints x 9
        RealMatrix d = null;
        try {
            d = new Array2DRowRealMatrix(numPoints, 9);
        } catch (NotStrictlyPositiveException e) {
// Path: app/src/main/java/org/librepilot/lp2go/VisualLog.java
// public class VisualLog {
// 
//     //private static Activity activity;
//     private static String nullstring = "null";
//     //private static TextView txtDebugLog;
// 
//     static private String checkNull(String msg) {
//         return msg == null ? nullstring : msg;
//     }
// 
//     static public void d(String tag, String msg) {
//         Log.d(tag, checkNull(msg));
//         printToDebug(tag, checkNull(msg));
//     }
// 
//     static public void e(String msg) {
//         e(new Exception().getStackTrace()[1].getClassName(), msg);
//     }
// 
//     static public void d(String msg) {
//         d(new Exception().getStackTrace()[1].getClassName(), msg);
//     }
// 
//     static public void d(String tag, String msg, Throwable tr) {
//         Log.e(tag, checkNull(msg), tr);
//         printToDebug(tag, checkNull(msg));
//         printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr));
//     }
// 
//     static public void w(String tag, String msg) {
//         Log.w(tag, checkNull(msg));
//         printToDebug(tag, checkNull(msg));
//     }
// 
//     static public void w(String msg) {
//         w(new Exception().getStackTrace()[1].getClassName(), msg);
//     }
// 
//     static public void e(String tag, String msg) {
//         Log.e(tag, checkNull(msg));
//         printToDebug(tag, checkNull(msg));
//     }
// 
//     static public void e(String tag, String msg, Throwable tr) {
//         Log.e(tag, checkNull(msg), tr);
//         printToDebug(tag, checkNull(msg));
//         printToDebug(tr.getClass().getSimpleName(), Log.getStackTraceString(tr));
//     }
// 
//     static public void e(String msg, Throwable tr) {
//         e(new Exception().getStackTrace()[1].getClassName(), msg, tr);
//     }
// 
//     static public void e(Throwable tr) {
//         VisualLog.e(tr.getClass().getSimpleName(), tr.getMessage(), tr);
//     }
// 
//     static public void i(String tag, String msg) {
//         Log.i(tag, checkNull(msg));
//         printToDebug(tag, checkNull(msg));
//     }
// 
//     static public void i(String msg) {
//         i(new Exception().getStackTrace()[1].getClassName(), checkNull(msg));
// 
//     }
// 
//     static private void printToDebug(final String t, final String s) {
//         /*
//         activity.runOnUiThread(new Runnable() {
//             @Override
//             public void run() {
//                 if (txtDebugLog != null) {
//                     txtDebugLog.append(t + " " + s + "\n");
//                 }
//             }
//         });
//         */
//     }
// 
//     public static void setActivity(Activity activity) {
//         //VisualLog.activity = activity;
//         //VisualLog.nullstring = activity.getString(R.string.NULL);
//     }
// 
//     public static void setDebugLogTextView(TextView txtDebugLog) {
//         //VisualLog.txtDebugLog = txtDebugLog;
//     }
// }


// Path: app/src/main/java/org/librepilot/lp2go/helper/ellipsoidFit/FitPoints.java
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.DecompositionSolver;
import org.apache.commons.math3.linear.EigenDecomposition;
import org.apache.commons.math3.linear.MatrixUtils;
import org.apache.commons.math3.linear.RealMatrix;
import org.apache.commons.math3.linear.RealVector;
import org.apache.commons.math3.linear.SingularValueDecomposition;
import org.librepilot.lp2go.VisualLog;
import java.util.Arrays;
import java.util.List;


        // Get the eigenvalues and eigenvectors.
        EigenDecomposition ed = new EigenDecomposition(subr, 0);
        evals = ed.getRealEigenvalues();
        evecs = ed.getEigenvector(0);
        evecs1 = ed.getEigenvector(1);
        evecs2 = ed.getEigenvector(2);

        // Find the radii of the ellipsoid.
        radii = findRadii(evals);
        return true;
    }

    /**
     * Solve the polynomial expression Ax^2 + By^2 + Cz^2 + 2Dxy + 2Exz + 2Fyz +
     * 2Gx + 2Hy + 2Iz from the provided points.
     *
     * @param points the points that will be fit to the polynomial expression.
     * @return the solution vector to the polynomial expression.
     */
    private RealVector solveSystem(List<? extends ThreeSpacePoint> points) {
        // determine the number of points
        int numPoints = points.size();

        // the design matrix
        // size: numPoints x 9
        RealMatrix d = null;
        try {
            d = new Array2DRowRealMatrix(numPoints, 9);
        } catch (NotStrictlyPositiveException e) {
            VisualLog.e("FitPoints", e.getMessage(), e);