tgranulargrain.c - granular - granular dynamics simulation
(HTM) git clone git://src.adamsgaard.dk/granular
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
tgranulargrain.c (1055B)
---
1 #include <stdlib.h>
2 #include <err.h>
3 #include <unistd.h>
4 #include "granular.h"
5 #include "arg.h"
6
7 char *argv0;
8
9 static void
10 usage(void)
11 {
12 errx(1, "usage: %s "
13 "[-d diameter] "
14 "[-f] "
15 "[-h] "
16 "[-R] "
17 "[-u vx] "
18 "[-v vy] "
19 "[-w vz] "
20 "[-x x] "
21 "[-y y] "
22 "[-z z]", argv0);
23 }
24
25 int
26 main(int argc, char *argv[])
27 {
28 struct grain g = grain_new();
29
30 #ifdef __OpenBSD__
31 if (pledge("stdio", NULL) == -1)
32 err(2, "pledge");
33 #endif
34
35 ARGBEGIN {
36 case 'd':
37 g.diameter = atof(EARGF(usage()));
38 break;
39 case 'f':
40 g.fixed = 1;
41 break;
42 case 'h':
43 usage();
44 break;
45 case 'R':
46 g.rotating = 0;
47 break;
48 case 'u':
49 g.vel[0] = atof(EARGF(usage()));
50 break;
51 case 'v':
52 g.vel[1] = atof(EARGF(usage()));
53 break;
54 case 'w':
55 g.vel[2] = atof(EARGF(usage()));
56 break;
57 case 'x':
58 g.pos[0] = atof(EARGF(usage()));
59 break;
60 case 'y':
61 g.pos[1] = atof(EARGF(usage()));
62 break;
63 case 'z':
64 g.pos[2] = atof(EARGF(usage()));
65 break;
66 default:
67 usage();
68 } ARGEND;
69
70 if (argc > 1)
71 usage();
72
73 grain_print(stdout, &g);
74
75 return 0;
76 }