in ConstraintLayoutExamples/CycleEditor/src/com/google/androidstudio/motionlayoutcycles/LinearInterpolator.java [71:105]
public void getPos(double t, float[] v) {
final int n = mT.length;
final int dim = mY[0].length;
if (t <= mT[0]) {
for (int j = 0; j < dim; j++) {
v[j] = (float) mY[0][j];
}
return;
}
if (t >= mT[n - 1]) {
for (int j = 0; j < dim; j++) {
v[j] = (float) mY[n - 1][j];
}
return;
}
for (int i = 0; i < n - 1; i++) {
if (t == mT[i]) {
for (int j = 0; j < dim; j++) {
v[j] = (float) mY[i][j];
}
}
if (t < mT[i + 1]) {
double h = mT[i + 1] - mT[i];
double x = (t - mT[i]) / h;
for (int j = 0; j < dim; j++) {
double y1 = mY[i][j];
double y2 = mY[i + 1][j];
v[j] = (float) (y1 * (1 - x) + y2 * x);
}
return;
}
}
}