| 1 |
greg |
1.1 |
#ifndef lint
|
| 2 |
schorsch |
2.4 |
static const char RCSid[] = "$Id: hermite3.c,v 2.3 2003/06/08 12:03:09 schorsch 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.4 |
void
|
| 37 |
schorsch |
2.3 |
htan3( /* compute tangent on hermite curve */
|
| 38 |
|
|
double ht[3], /* returned hermite tangent */
|
| 39 |
|
|
double p0[3], /* first endpoint */
|
| 40 |
|
|
double p1[3], /* second endpoint */
|
| 41 |
|
|
double r0[3], /* tangent at p0 */
|
| 42 |
|
|
double r1[3], /* tangent at p1 */
|
| 43 |
|
|
double t /* position parameter */
|
| 44 |
|
|
)
|
| 45 |
greg |
1.1 |
{
|
| 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 |
|
|
}
|