home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / NEWS / RADIANCE / CAL / SPLINE.CAL < prev    next >
Text File  |  1993-10-07  |  835b  |  39 lines

  1. {
  2.     Calculation of view parameters for walk-throughs.
  3.     Uses Catmull-Rolm spline.
  4.  
  5.         09Feb90 Greg Ward
  6.  
  7.     Define:
  8.         T(i)    - time between keyframe i and i-1
  9.     Input:
  10.         t    - time
  11.     Output:
  12.         s(f)    - spline value for f at t where f(i) is value at T(i)
  13. }
  14.  
  15. s(f) = hermite(f(below), f(above),
  16.         (f(above)-f(below2))/2, (f(above2)-f(below))/2,
  17.         tfrac);
  18.  
  19. tfrac =    (t-sum(T,below))/T(above);
  20. Ttot = sum(T,T(0));
  21.  
  22. below = above-1;
  23. above = max(upper(0,1),2);
  24. below2 = max(below-1,1);
  25. above2 = min(above+1,T(0));
  26.  
  27. upper(s,i) = if(or(i-T(0)+.5,s+T(i)-t), i, upper(s+T(i),i+1));
  28.  
  29. sum(f,n) = if(n-.5, f(n)+sum(f,n-1), 0);
  30.  
  31. or(a,b) = if(a, a, b);
  32. min(a,b) = if(a-b, b, a);
  33. max(a,b) = if(a-b, a, b);
  34.  
  35. hermite(p0,p1,r0,r1,t) =    p0 * ((2*t-3)*t*t+1) +
  36.                 p1 * (-2*t+3)*t*t +
  37.                 r0 * (((t-2)*t+1)*t) +
  38.                 r1 * ((t-1)*t*t);
  39.