Back to index

radiance  4R0+20100331
hermite3.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: hermite3.c,v 2.4 2003/11/16 10:29:38 schorsch Exp $";
00003 #endif
00004 /*
00005  *  hermite.c - routines for 3D hermite curves.
00006  *
00007  *     10/29/85
00008  */
00009 
00010 #include  <stdio.h>
00011 
00012 void
00013 hermite3(            /* compute point on hermite curve */
00014 double  hp[3],              /* returned hermite point */
00015 double  p0[3],              /* first endpoint */
00016 double  p1[3],              /* second endpoint */
00017 double  r0[3],              /* tangent at p0 */
00018 double  r1[3],              /* tangent at p1 */
00019 double  t            /* position parameter */
00020 )
00021 {
00022        register int  i;
00023        double  tmh[4];
00024        
00025        tmh[0] = (2.0*t - 3.0)*t*t + 1.0;
00026        tmh[1] = (-2.0*t + 3.0)*t*t;
00027        tmh[2] = ((t - 2.0)*t + 1.0)*t;
00028        tmh[3] = (t - 1.0)*t*t;
00029        
00030        for (i = 0; i < 3; i++)
00031               hp[i] = p0[i]*tmh[0] + p1[i]*tmh[1] +
00032                      r0[i]*tmh[2] + r1[i]*tmh[3];
00033 }
00034 
00035 
00036 void
00037 htan3(        /* compute tangent on hermite curve */
00038 double  ht[3],              /* returned hermite tangent */
00039 double  p0[3],              /* first endpoint */
00040 double  p1[3],              /* second endpoint */
00041 double  r0[3],              /* tangent at p0 */
00042 double  r1[3],              /* tangent at p1 */
00043 double  t            /* position parameter */
00044 )
00045 {
00046        register int  i;
00047        double  tpmh[4];
00048        
00049        tpmh[0] = (6.0*t - 6.0)*t;
00050        tpmh[1] = (-6.0*t + 6.0)*t;
00051        tpmh[2] = (3.0*t - 4.0)*t + 1.0;
00052        tpmh[3] = (3.0*t - 2.0)*t;
00053        
00054        for (i = 0; i < 3; i++)
00055               ht[i] = p0[i]*tpmh[0] + p1[i]*tpmh[1] +
00056                      r0[i]*tpmh[2] + r1[i]*tpmh[3];
00057 }