home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
RADIANCE
/
CAL
/
SPLINE.CAL
< prev
next >
Wrap
Text File
|
1993-10-07
|
835b
|
39 lines
{
Calculation of view parameters for walk-throughs.
Uses Catmull-Rolm spline.
09Feb90 Greg Ward
Define:
T(i) - time between keyframe i and i-1
Input:
t - time
Output:
s(f) - spline value for f at t where f(i) is value at T(i)
}
s(f) = hermite(f(below), f(above),
(f(above)-f(below2))/2, (f(above2)-f(below))/2,
tfrac);
tfrac = (t-sum(T,below))/T(above);
Ttot = sum(T,T(0));
below = above-1;
above = max(upper(0,1),2);
below2 = max(below-1,1);
above2 = min(above+1,T(0));
upper(s,i) = if(or(i-T(0)+.5,s+T(i)-t), i, upper(s+T(i),i+1));
sum(f,n) = if(n-.5, f(n)+sum(f,n-1), 0);
or(a,b) = if(a, a, b);
min(a,b) = if(a-b, b, a);
max(a,b) = if(a-b, a, b);
hermite(p0,p1,r0,r1,t) = p0 * ((2*t-3)*t*t+1) +
p1 * (-2*t+3)*t*t +
r0 * (((t-2)*t+1)*t) +
r1 * ((t-1)*t*t);