ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/spline.cal
Revision: 1.3
Committed: Mon Jun 10 13:56:52 2019 UTC (4 years, 11 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R3, HEAD
Changes since 1.2: +1 -3 lines
Log Message:
Added max() and min() as .cal library functions

File Contents

# Content
1 { RCSid $Id: spline.cal,v 1.2 2018/11/21 18:10:45 greg Exp $ }
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
19 hermite(p0,p1,r0,r1,t) : p0 * ((2*t-3)*t*t+1) +
20 p1 * (-2*t+3)*t*t +
21 r0 * (((t-2)*t+1)*t) +
22 r1 * ((t-1)*t*t);
23 Ttot : sum(T,T(0));
24
25 sum(f,n) : if(n-.5, f(n)+sum(f,n-1), 0);
26
27 tfrac = (t-sum(T,below))/T(above);
28
29 upper(s,i) = if(or(i-T(0)+.5,s+T(i)-t), i, upper(s+T(i),i+1));
30
31 below = above-1;
32 above = max(upper(0,1),2);
33 below2 = max(below-1,1);
34 above2 = min(above+1,T(0));
35
36 s(f) = hermite(f(below), f(above),
37 (f(above)-f(below2))/2, (f(above2)-f(below))/2,
38 tfrac);