Just interpolate between the starting height and the ending height. And you will get a smooth function. Afterwards, apply verlet integration for smooth transitioning. In short, just animate it crouching. But realize that crouching shouldn't take much cpu. So another suggestion is to have something like this :
void display(){
//...
if( KEY_DOWN_PRESSED && canCrouch){
int steps = 2;
const int END_X_POS = 5;
for(int i = 0; i < steps; ++i){
crouch( END_X_POS/float(steps) );
redisplayPlayer();
}
}
}
void crouch(const int delta){
entity[0].crouching = true;
entity[0].centre_height = PLAYER_HEIGHT / delta;
entity[0].height = PLAYER_HEIGHT / (delta/2);
entity[0].gun_position.x = 0.0;
entity[0].gun_position.y = entity[0].height - 1.0;
entity[0].gun_position.z = 0.0;
}
so the idea in above is to have multiple crouch in between starting(0) and ending(5) and display its position. This is cheaper than original suggestion and probably shows decent result.