Hi! - I’m trying to convert some cubic easing functions from Actionscript to Wiring for use in some motor controller code I am writing. The AS code I am using is based on examples/tutorials by Robert Penner (good stuff: Robert Penner's Easing Functions). The function I am testing is ‘easeInOutCubic’.

When I run it in Wiring I expected to get stepped values from the *start* value to the *change* value. Instead what I am getting is: a run of 60, then 1305 in the Serial output window. I understand that Serial.print() truncates floats but I expected to see a range from 60 (start) to 2490 (change amount).

I’m guessing I have some problem with data typing - but that’s a guess. Where I am going with this is to use the easing functions to PWM my motor so it doesn’t lurch to full speed but gradually eases in/out.

Anyway - hope this is clear : - Any nudges in the right direction much appreciated!

–Roy

**-------------ActionScript**

```
function easeInOutCubic(t, b, c, d) {
if ((t /= d/2)<1) {
return c/2*Math.pow(t, 3)+b;
}
return c/2*(Math.pow(t-2, 3)+2)+b;
}
```

**-----------Wiring**

```
//
int time;
int start;
int end;
int change;
int duration;
float speed;
boolean active;
void setup(){
Serial.begin(115200);
start = 60;
end =2550;
change = end - start;
time = 0;
duration = 50 ;
active = true;
}
void loop(){
if (active == true){
speed = easeInCubic(time++, start, change, duration);
Serial.println(speed, DEC);
if (time ==duration){
active = false;
}
}
}
float easeInOutCubic(int t, int b, int c, int d) {
if ((t /= d/2)<1) {
return c/2* pow(t, 3)+b;
}
return c/2*(pow(t-2, 3)+2)+b;
}
float easeInCubic(int t, int b, int c, int d) {
return c * pow (t/d, 3) + b;
};
float easeOutCubic(int t, int b, int c, int d) {
return c * (pow (t/d-1, 3) + 1) + b;
};
```