public double getLength2D(double t) {
    final int n = mT.length;
    final int dim = mY[0].length;
    if (dim < 2) {
      return 0;
    }
    if (t <= mT[0]) { // before start does not count
      return 0;
    }
    if (t >= mT[n - 1]) {
      t = mT[n - 1]; // clamp to the end
    }
    double sum = 0;

    for (int i = 0; i < n - 1; i++) {
      if (t == mT[i]) {
        double x = mY[i][0];
        double y = mY[i][1];

      }
      if (t >= mT[i + 1]) {
        double h = mT[i + 1] - mT[i];
        double x = 1;
        double x1 = mY[i][0];
        double x2 = mY[i + 1][0];
        double tx1 = mTangent[i][0];
        double tx2 = mTangent[i + 1][0];
        double ix = length(h, x, x1, x2, tx1, tx2);
        double y1 = mY[i][1];
        double y2 = mY[i + 1][1];
        double ty1 = mTangent[i][1];
        double ty2 = mTangent[i + 1][1];
        double iy = length(h, x, y1, y2, ty1, ty2);

      } else if (t < mT[i + 1]) {
        double h = mT[i + 1] - mT[i];
        double x = (t - mT[i]) / h;
        double x1 = mY[i][0];
        double x2 = mY[i + 1][0];
        double tx1 = mTangent[i][0];
        double tx2 = mTangent[i + 1][0];
        double ix = length(h, x, x1, x2, tx1, tx2);
        double y1 = mY[i][1];
        double y2 = mY[i + 1][1];
        double ty1 = mTangent[i][1];
        double ty2 = mTangent[i + 1][1];
        double iy = length(h, x, y1, y2, ty1, ty2);

      }
    }
    return 0;
  }
This performs a spline interpolation in multiple dimensions
ConstraintLayoutExamples/CycleEditor/src/com/google/androidstudio/motionlayoutcycles/MonotoneSpline.java