ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/spline.cal
Revision: 1.1
Committed: Sat Feb 22 02:07:21 2003 UTC (21 years, 1 month ago) by greg
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R5, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 {
2 Calculation of view parameters for walk-throughs.
3 Uses Catmull-Rom 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
16 or(a,b) : if(a, a, b);
17 min(a,b) : if(a-b, b, a);
18 max(a,b) : if(a-b, a, b);
19
20 hermite(p0,p1,r0,r1,t) : p0 * ((2*t-3)*t*t+1) +
21 p1 * (-2*t+3)*t*t +
22 r0 * (((t-2)*t+1)*t) +
23 r1 * ((t-1)*t*t);
24 Ttot : sum(T,T(0));
25
26 sum(f,n) : if(n-.5, f(n)+sum(f,n-1), 0);
27
28 tfrac = (t-sum(T,below))/T(above);
29
30 upper(s,i) = if(or(i-T(0)+.5,s+T(i)-t), i, upper(s+T(i),i+1));
31
32 below = above-1;
33 above = max(upper(0,1),2);
34 below2 = max(below-1,1);
35 above2 = min(above+1,T(0));
36
37 s(f) = hermite(f(below), f(above),
38 (f(above)-f(below2))/2, (f(above2)-f(below))/2,
39 tfrac);