| 1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* genbeads.c - generate a string of spheres using Hermite |
| 6 |
|
* curve specification. |
| 9 |
|
*/ |
| 10 |
|
|
| 11 |
|
#include <stdio.h> |
| 12 |
+ |
#include <stdlib.h> |
| 13 |
|
#include <math.h> |
| 14 |
|
|
| 15 |
< |
char *mtype; /* material type */ |
| 15 |
> |
void hermite3(double hp[3], double p0[3], double p1[3], |
| 16 |
> |
double r0[3], double r1[3], double t); |
| 17 |
> |
void htan3(double ht[3], double p0[3], double p1[3], |
| 18 |
> |
double r0[3], double r1[3], double t); |
| 19 |
|
|
| 20 |
< |
char *name; /* name */ |
| 20 |
> |
static void genstring( |
| 21 |
> |
char *mtype, |
| 22 |
> |
char *name, |
| 23 |
> |
double p0[3], |
| 24 |
> |
double p1[3], |
| 25 |
> |
double r0[3], |
| 26 |
> |
double r1[3], |
| 27 |
> |
double rad, |
| 28 |
> |
double inc |
| 29 |
> |
) |
| 30 |
> |
{ |
| 31 |
> |
register int i; |
| 32 |
> |
double v[3]; |
| 33 |
> |
double t; |
| 34 |
> |
|
| 35 |
> |
t = 0.0; |
| 36 |
> |
for (i = 0; t <= 1.0; i++) { |
| 37 |
|
|
| 38 |
< |
#ifdef DCL_ATOF |
| 39 |
< |
extern double atof(); |
| 40 |
< |
#endif |
| 38 |
> |
printf("\n%s sphere %s.%d\n", mtype, name, i); |
| 39 |
> |
|
| 40 |
> |
hermite3(v, p0, p1, r0, r1, t); |
| 41 |
> |
|
| 42 |
> |
printf("0\n0\n4 %18.12g %18.12g %18.12g %18.12g\n", |
| 43 |
> |
v[0], v[1], v[2], rad); |
| 44 |
|
|
| 45 |
+ |
htan3(v, p0, p1, r0, r1, t); |
| 46 |
+ |
t += inc / sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); |
| 47 |
+ |
} |
| 48 |
+ |
} |
| 49 |
|
|
| 50 |
< |
main(argc, argv) |
| 27 |
< |
int argc; |
| 28 |
< |
char **argv; |
| 50 |
> |
int main(int argc, char **argv) |
| 51 |
|
{ |
| 52 |
|
double p0[3], p1[3], r0[3], r1[3]; |
| 53 |
|
double rad, inc; |
| 54 |
+ |
char *mtype; /* material type */ |
| 55 |
+ |
char *name; /* name */ |
| 56 |
|
|
| 57 |
|
if (argc != 17) { |
| 58 |
|
fprintf(stderr, "Usage: %s material name p0 p1 r0 r1 rad inc\n", |
| 81 |
|
return(0); |
| 82 |
|
} |
| 83 |
|
|
| 60 |
– |
|
| 61 |
– |
genstring(mtype, name, p0, p1, r0, r1, rad, inc) |
| 62 |
– |
char *mtype; |
| 63 |
– |
char *name; |
| 64 |
– |
double p0[3]; |
| 65 |
– |
double p1[3]; |
| 66 |
– |
double r0[3]; |
| 67 |
– |
double r1[3]; |
| 68 |
– |
double rad; |
| 69 |
– |
double inc; |
| 70 |
– |
{ |
| 71 |
– |
register int i; |
| 72 |
– |
double v[3]; |
| 73 |
– |
double t; |
| 74 |
– |
|
| 75 |
– |
t = 0.0; |
| 76 |
– |
for (i = 0; t <= 1.0; i++) { |
| 77 |
– |
|
| 78 |
– |
printf("\n%s sphere %s.%d\n", mtype, name, i); |
| 79 |
– |
|
| 80 |
– |
hermite3(v, p0, p1, r0, r1, t); |
| 81 |
– |
|
| 82 |
– |
printf("0\n0\n4 %18.12g %18.12g %18.12g %18.12g\n", |
| 83 |
– |
v[0], v[1], v[2], rad); |
| 84 |
– |
|
| 85 |
– |
htan3(v, p0, p1, r0, r1, t); |
| 86 |
– |
t += inc / sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); |
| 87 |
– |
} |
| 88 |
– |
} |