// Project P1a // Implement the following functions as suggested (do not use f7 to implement them) // constant speed in [0,1] float f1(float t) {return(t);} // constant acceleration in [0,0.5], then constant deceleration (Hint: solve second degree equation for the accelration value) float f2(float t) {float r=2*t*t; if (t>0.5) r=1-(2*(1-t)*(1-t)); return(r);} // more dynamic than f2: more acceleration at first and breaks later (Hint: use cos) float f3(float t) {return((1+cos(PI+t*PI))/2.0);} // heavy car: slow start then breaks hard (Hint: use cos power or rational function) float f4(float t) {return(sq(sq(cos((1-t)*PI/2 ))));} // wind up first and overshoot a bit (Hint: use cubic Bezier) float f5(float t) {return(cubic(-0.3,t,1.08));} float cubic(float a, float t, float b) {return( i(i(i(0,t,a),t,i(a,t,b)), t ,i(i(a,t,b),t,i(b,t,1))) ); } float i(float a, float t, float b) {return(a+t*(b-a));} // start with high speed, then slows down (Hint: use cubic with different values) float f6(float t) {return(cubic(0.8,t,1));}