Пример #1
0
void csCubicSpline::PrecalculateDerivatives ()
{
  if (precalculation_valid) return ;
  precalculation_valid = true;
  delete[] derivative_points;
  derivative_points = new float[dimensions * num_points];

  int dim;
  for (dim = 0; dim < dimensions; dim++) PrecalculateDerivatives (dim);
}
Пример #2
0
void csCubicSpline::Calculate (float time)
{
  PrecalculateDerivatives ();

  // First find the current 'idx'.
  for (idx = 0; idx < num_points - 1; idx++)
  {
    if (time >= time_points[idx] && time <= time_points[idx + 1]) break;
  }

  A = (time_points[idx + 1] - time) / (time_points[idx + 1] - time_points[idx]);
  B = 1 - A;

  float temp = (time_points[idx + 1] - time_points[idx]);
  temp = temp * temp / 6.0f;
  C = (A * A * A - A) * temp;
  D = (B * B * B - B) * temp;
}
Пример #3
0
void csCubicSpline::Calculate (float time)
{
  PrecalculateDerivatives ();

  // First find the current 'idx'.
  for (idx = 0; idx < num_points - 1; idx++)
  {
    if (time >= time_points[idx] && time <= time_points[idx + 1]) break;
  }

  // Correct for floating point inaccuracies in the previous loop.
  if (idx == num_points-1) idx--;

  A = (time_points[idx + 1] - time) / (time_points[idx + 1] - time_points[idx]);
  B = 1 - A;

  float temp = (time_points[idx + 1] - time_points[idx]);
  temp = temp * temp / 6.0f;
  C = (A * A * A - A) * temp;
  D = (B * B * B - B) * temp;
}