package org.ratchetrobotics.algorithms.utilities;

import org.ratchetrobotics.algorithms.ai.ResponseCurve;

/**
 * Created by liam on 10/8/15.
 */
public class JoystickScaler {
  private ResponseCurve responseCurve;

  public JoystickScaler() {
    responseCurve = new ResponseCurve(new double[]{0.0, 0.25, 0.75, 1.0},
      new double[]{0.0, 0.3, 0.8, 1});
  }

  public double in(double input) {
    double response = Math.abs(responseCurve.respond(Math.abs(input)));
    return (input > 0) ? (response) : (-response);
  }
}

@@ -399,75 +399,471 @@
     
-double response = Math.abs(responseCurve.respond(Math.abs(input)));
+// there is a good reason for all the Math.abs on the next line.%0A    // we clamp the input to %5B0, 1%5D from the joystick. then we clamp the output of .respond to %5B0, 1%5D as well.%0A    // this is to not have to manually mirror the response curve on %5B-1, 0%5D.%0A    double response = Math.abs(responseCurve.respond(Math.abs(input)));%0A    // this line re-adds the correct sign. this makes it impossible for a screwy interpolation%0A    // to run motors in the wrong direction
 %0A   

comment all the things!