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 |
+ |
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 *mtype; /* material type */ |
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 |
< |
char *name; /* name */ |
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) |
23 |
< |
int argc; |
24 |
< |
char **argv; |
50 |
> |
int main(int argc, char **argv) |
51 |
|
{ |
26 |
– |
double atof(); |
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 |
|
|
57 |
– |
|
58 |
– |
genstring(mtype, name, p0, p1, r0, r1, rad, inc) |
59 |
– |
char *mtype; |
60 |
– |
char *name; |
61 |
– |
double p0[3]; |
62 |
– |
double p1[3]; |
63 |
– |
double r0[3]; |
64 |
– |
double r1[3]; |
65 |
– |
double rad; |
66 |
– |
double inc; |
67 |
– |
{ |
68 |
– |
double sqrt(); |
69 |
– |
register int i; |
70 |
– |
double v[3]; |
71 |
– |
double t; |
72 |
– |
|
73 |
– |
t = 0.0; |
74 |
– |
for (i = 0; t <= 1.0; i++) { |
75 |
– |
|
76 |
– |
printf("\n%s sphere %s.%d\n", mtype, name, i); |
77 |
– |
|
78 |
– |
hermite3(v, p0, p1, r0, r1, t); |
79 |
– |
|
80 |
– |
printf("0\n0\n4 %18.12g %18.12g %18.12g %18.12g\n", |
81 |
– |
v[0], v[1], v[2], rad); |
82 |
– |
|
83 |
– |
htan3(v, p0, p1, r0, r1, t); |
84 |
– |
t += inc / sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); |
85 |
– |
} |
86 |
– |
} |