punchtable.c
2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* This silly little program does the "in-betweening" and builds
* angle tables for a punch cycle.
*
*/
#include <stdio.h>
float la[64], lw[64], ra[64], rw[64];
#define PUNCH_CYCLE_LENGTH 10
#define L_ARM_INITIAL 0.0
#define R_ARM_INITIAL -45.0
#define L_WRIST_INITIAL -120.0
#define R_WRIST_INITIAL -90.0
#define L_ARM_FINAL -90.0
#define R_ARM_FINAL -90.0
#define L_WRIST_FINAL -10.0
#define R_WRIST_FINAL -5.0
/*
*
*/
int
main(int argc, char *argv[])
{
int i, j, max_frames, key1, key2, key3;
float lai, lwi, rai, rwi;
while ((argc > 1) && (argv[1][0] == '-')) {
switch(argv[1][1]) {
default:
fprintf(stderr,"option [%s] not recognized.\n", argv[1]);
break;
}
argc--;
argv++;
}
max_frames = PUNCH_CYCLE_LENGTH;
key1 = max_frames/2;
la[0] = L_ARM_INITIAL;
lw[0] = L_WRIST_INITIAL;
ra[0] = R_ARM_INITIAL;
rw[0] = R_WRIST_INITIAL;
lai = (L_ARM_FINAL - L_ARM_INITIAL)/key1;
lwi = (L_WRIST_FINAL - L_WRIST_INITIAL)/key1;
rai = (R_ARM_FINAL - R_ARM_INITIAL)/key1;
rwi = (R_WRIST_FINAL - R_WRIST_INITIAL)/key1;
for (i=1; i<max_frames; i++) {
la[i] = la[i-1] + lai;
lw[i] = lw[i-1] + lwi;
ra[i] = ra[i-1] + rai;
rw[i] = rw[i-1] + rwi;
if (i == key1) {
lai = -lai;
lwi = -lwi;
rai = -rai;
rwi = -rwi;
}
}
fprintf(stdout,"\n/* ---- GENERATED FILE, DO NOT EDIT ---- */\n\n");
fprintf(stdout,"/*\n * punchtable.h\n *\n");
fprintf(stdout," * This file holds the punch cycle angle tables.\n *\n */\n");
fprintf(stdout,"\n#define PUNCH_CYCLE_LEN\t%d\n\n",max_frames+1);
fprintf(stdout,"float left_arm[] =\n{\n");
for (i=0; i<max_frames; i++) {
fprintf(stdout,"\t%f,\n",la[i]);
}
fprintf(stdout,"\t%f\n",L_ARM_INITIAL);
fprintf(stdout,"};\n\n");
fprintf(stdout,"float left_wrist[] =\n{\n");
for (i=0; i<max_frames; i++) {
fprintf(stdout,"\t%f,\n",lw[i]);
}
fprintf(stdout,"\t%f\n",L_WRIST_INITIAL);
fprintf(stdout,"};\n\n");
fprintf(stdout,"float right_arm[] =\n{\n");
for (i=0; i<max_frames; i++) {
fprintf(stdout,"\t%f,\n",ra[i]);
}
fprintf(stdout,"\t%f\n",R_ARM_INITIAL);
fprintf(stdout,"};\n\n");
fprintf(stdout,"float right_wrist[] =\n{\n");
for (i=0; i<max_frames; i++) {
fprintf(stdout,"\t%f,\n",rw[i]);
}
fprintf(stdout,"\t%f\n",R_WRIST_INITIAL);
fprintf(stdout,"};\n\n");
}