Thank you very much Mike, the zooming is now at constant speed!, finally
. I also managed to write a function that estimates the value of "k" acording to a given start and destination value, it returns a value that
almost reaches the destination value on the last frame. This function allows me to set a given start and end keyframe of the zoom and let the user decide the framerate and an exact transition time.
This is code of the function if anyone is intrested:
double GetExponentForRange(double start_value, double end_value, int frames_in_transition)
{
int frame, i;
double exponent, prev_exponent=0.0, current_value, step;
const double step_multiplier=1.0100000000000000; //1.0001000000000000 = more accurate but slow
if(start_value>end_value)
{
exponent=-0.0000000000000001;
for(i=0; i<2; i++)
{
for(step=0.0000000000000001; ; prev_exponent=exponent, exponent-=step, step*=step_multiplier)
{
for(frame=1; frame<frames_in_transition; frame++)
{
current_value=start_value * pow(10.0, exponent*double(frame));
}
if(current_value<end_value) break;
prev_exponent=exponent;
}
exponent=prev_exponent; //and again for better precision, beginning with the last zoom factor that has been estimated
}
}
else if(start_value<end_value)
{
exponent=0.0000000000000001;
for(i=0; i<2; i++)
{
for(step=0.0000000000000001; ; prev_exponent=exponent, exponent+=step, step*=step_multiplier)
{
for(frame=1; frame<frames_in_transition; frame++)
{
current_value=start_value * pow(10.0, exponent*double(frame));
}
if(current_value>end_value) break;
prev_exponent=exponent;
}
exponent=prev_exponent; //and again for better precision, beginning with the last zoom factor that has been estimated
}
}
return prev_exponent;
}
This is my first mathematical "brute force" function
Maybe you know an easier approach.
If im honest im not really happy with this situation because i have to limit the waypoint functionality so the user can either zoom OR move the view rect. To make a zoom into a specified position you have to go to the destination place, then zoom out, set the first keyframe and then zoom again to set the second keyframe. Now i understand why it is complicated to combine both transition types, they are dependent on each other.
Smooth starting and stopping is a "nice to have fancy", but combining both zooming and moving is much more intresting for me. Maybe you can post a solution for this some day, that would be really cool, but you already deserved a thanks and a place in the credits section of my software