ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/hermite3.c
Revision: 1.1
Committed: Thu Feb 2 11:16:31 1989 UTC (35 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 greg 1.1 /* Copyright (c) 1986 Regents of the University of California */
2    
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6    
7     /*
8     * hermite.c - routines for 3D hermite curves.
9     *
10     * 10/29/85
11     */
12    
13     #include <stdio.h>
14    
15    
16     hermite3(hp, p0, p1, r0, r1, t) /* compute point on hermite curve */
17     double hp[3]; /* returned hermite point */
18     double p0[3]; /* first endpoint */
19     double p1[3]; /* second endpoint */
20     double r0[3]; /* tangent at p0 */
21     double r1[3]; /* tangent at p1 */
22     double t; /* position parameter */
23     {
24     register int i;
25     double tmh[4];
26    
27     tmh[0] = (2.0*t - 3.0)*t*t + 1.0;
28     tmh[1] = (-2.0*t + 3.0)*t*t;
29     tmh[2] = ((t - 2.0)*t + 1.0)*t;
30     tmh[3] = (t - 1.0)*t*t;
31    
32     for (i = 0; i < 3; i++)
33     hp[i] = p0[i]*tmh[0] + p1[i]*tmh[1] +
34     r0[i]*tmh[2] + r1[i]*tmh[3];
35     }
36    
37    
38     htan3(ht, p0, p1, r0, r1, t) /* compute tangent on hermite curve */
39     double ht[3]; /* returned hermite tangent */
40     double p0[3]; /* first endpoint */
41     double p1[3]; /* second endpoint */
42     double r0[3]; /* tangent at p0 */
43     double r1[3]; /* tangent at p1 */
44     double t; /* position parameter */
45     {
46     register int i;
47     double tpmh[4];
48    
49     tpmh[0] = (6.0*t - 6.0)*t;
50     tpmh[1] = (-6.0*t + 6.0)*t;
51     tpmh[2] = (3.0*t - 4.0)*t + 1.0;
52     tpmh[3] = (3.0*t - 2.0)*t;
53    
54     for (i = 0; i < 3; i++)
55     ht[i] = p0[i]*tpmh[0] + p1[i]*tpmh[1] +
56     r0[i]*tpmh[2] + r1[i]*tpmh[3];
57     }