Exemplo n.º 1
0
// given  global t, returns the point in the curve
void getGlobalCatmullRomPoint(float **p,int point_count, float gt, float *res) {

	float t = gt * point_count; // this is the real global t
	int index = floor(t);  // which segment
	t = t - index; // where within  the segment

	// indices store the points
	int indices[4];
	indices[0] = (index + point_count - 1) % point_count;	indices[1] = (indices[0] + 1) % point_count;
	indices[2] = (indices[1] + 1) % point_count; indices[3] = (indices[2] + 1) % point_count;

	getCatmullRomPoint(p, t, indices, res);
}
// given  global t, returns the point in the curve
void TranslationCatmull::getGlobalCatmullRomPoint(float gt, float *res) {
  float t   = gt * nControlPoints; // this is the real global t
  int index = (int) t;             // which segment
  t         = t - index;           // where within  the segment

  // indices store the points
  int indices[4];
  indices[0] = index % nControlPoints;
  indices[1] = (index + 1) % nControlPoints;
  indices[2] = (index + 2) % nControlPoints;
  indices[3] = (index + 3) % nControlPoints;

  getCatmullRomPoint(t, indices, res);
}