package rocketpower.library;


public class TrackKey implements Comparable<TrackKey> {
    public enum KeyType {
        STEP,
        LINEAR,
        SMOOTH,
        RAMP
    }

    private int row;
    private float value;
    private KeyType keyType;

    public TrackKey(int row, float value, KeyType keyType) {
        this.row = row;
        this.value = value;
        this.keyType = keyType;
    }

    public int getRow() {
        return row;
    }

    public float getValue() {
        return value;
    }

    public KeyType getKeyType() {
        return keyType;
    }

    public int compareTo(TrackKey other) {
        return row > other.row ? 1 : row < other.row ? -1 : 0;
    }

    public String toString() {
        return String.format("TrackKey(row=%d value=%f type=%s)", row, value, keyType);
    }
}

@@ -814,11 +814,540 @@
 );%0A    %7D
+%0A%0A    public static double interpolate(TrackKey first, TrackKey second, double row) %7B%0A        double t = (row - first.row) / (second.row - first.row);%0A%0A        switch (first.keyType) %7B%0A            case STEP:%0A                return first.value;%0A            //case KeyType.LINEAR:%0A            case SMOOTH:%0A                t = t * t * (3 - 2*t);%0A                break;%0A            case RAMP:%0A                t = Math.pow(t, 2.0);%0A                break;%0A        %7D%0A%0A        return first.value + (second.value - first.value) * t;%0A    %7D
 %0A%7D%0A

Implement interpolation between TrackKeys