ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/spline.cal
Revision: 1.2
Committed: Wed Nov 21 18:10:45 2018 UTC (5 years, 6 months ago) by greg
Branch: MAIN
Changes since 1.1: +1 -0 lines
Log Message:
Added missing RCSid tag

File Contents

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