public void doJerkStuff() {
        double time = 0;
        //calculate acceleration
        ArrayList<Segment> p = pathSegments.s;
//        for (int i = 1; i < p.size(); i++) {
//            double dv = p.get(i).vel - p.get(i - 1).vel;
//            double dt = p.get(i).time - p.get(i - 1).vel;
//            p.get(i).acc = dv / dt;
//        }
        //peform Jared Russell's method on acc/position curve.
        for (int i = 1; i < p.size(); i++) {
            double a_0 = p.get(i - 1).acc;
            double dx = p.get(i - 1).dx;
            if (dx != 0) {
                double a_max = Math.sqrt(Math.abs(a_0 * a_0 + 2 * max_jerk * dx));
                double a = Math.min(a_max, p.get(i).acc);
                if (Double.isNaN(a)) {
                    a = 0;
                }
                p.get(i).acc = a;
            } else {
                p.get(i).acc = 0;
            }
        }

        for (int i = p.size() - 2; i > 1; i--) {
            double a_0 = p.get(i + 1).acc;
            double dx = p.get(i + 1).dx;
            double a_max = Math.sqrt(Math.abs(a_0 * a_0 + 2 * max_jerk * dx));
            double a = Math.min((Double.isNaN(a_max) ? max_acc : a_max), p.get(i).acc);
            p.get(i).acc = a;
        }
        //recalculate velocity, using only dx and acceleration, as velocity
        //is max velocity with acc. limits, and may not always be achieved
        //with jerk limits in place.
        p.get(0).vel = 0;
        for (int i = 1; i < p.size(); i++) {
            double v_0 = p.get(i - 1).vel;
            double dx = p.get(i).posit - p.get(i - 1).posit;
            double a = (p.get(i).acc + p.get(i - 1).acc) / 2;
            a = (Double.isNaN(a)) ? 0 : a;
            double v_f = Math.sqrt(Math.abs(v_0 * v_0 + 2 * a * dx));
            p.get(i).vel = v_f;
            //System.out.println(v_f);
        }
        //recalculate time
        for (int i = 1; i < p.size(); i++) {
            double v = p.get(i).vel;
            double dx = p.get(i - 1).dx;
            double v_0 = p.get(i - 1).vel;
            time = time + (2 * dx) / (v + v_0);
            time = (Double.isNaN(time)) ? 0 : time;
            p.get(i).time = time;
            //System.out.println(time);
        }
        //Util.makeGraph(pathSegments, "test", "tet");
    }