Java tutorial
//package com.java2s; import java.util.List; public class Main { public static float getOffset(int from, int move, float progress, float startX, float oldStartX, List<Float> gaps, List<Float> oldGaps) { float dist = startX; for (int i = 0; i < move; i++) { dist += gaps.get(i); } float cur = oldStartX; for (int i = 0; i < from; i++) { cur += oldGaps.get(i); } return cur + (dist - cur) * progress; } }