Picked up this handy little function while reading "Programming an RTS Game with Direct3D". It's an alternative to linear interpolation that interpolates a cosine wave between 2 points:
float CosineInterpolate(float v1, float v2, float a) {
float angle = a * PI;
float prc = (1.0f - cos(angle)) * 0.5f;
return v1 * (1.0f - prc) + v2*prc;
}
This results in a smoother interpolation between the two points.
Tuesday, August 18, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment