ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/hermite3.c
Revision: 2.3
Committed: Sun Jun 8 12:03:09 2003 UTC (20 years, 9 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 2.2: +18 -16 lines
Log Message:
Reduced compile warnings/errors on Windows.

File Contents

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