gp2rml/gp2rml.c |
60 | 60 | static double z_scale = 1; /* < 1: compress; > 1: stretch */ |
61 | 61 | |
62 | 62 | |
63 | | #define units(mm) ((int) round((mm)*40.0)) |
| 63 | #define units(mm) ((int) round((mm) * 40.0)) |
64 | 64 | |
65 | 65 | |
66 | 66 | #define alloc_type(t) \ |
... | ... | |
146 | 146 | printf("!PZ%d,%d;PA%d,%d;PD\n", |
147 | 147 | units(seg->z-z_max), units(z_clear), |
148 | 148 | units(seg->x), units(seg->y)); |
149 | | d = hypot(x-seg->x, y-seg->y); |
| 149 | d = hypot(x - seg->x, y - seg->y); |
150 | 150 | s += d; |
151 | | s += z-z_max; |
152 | | t += d/V_MAX; |
153 | | t += (z-z_max)/z_speed; |
| 151 | s += z - z_max; |
| 152 | t += d / V_MAX; |
| 153 | t += (z - z_max) / z_speed; |
154 | 154 | x = seg->x; |
155 | 155 | y = seg->y; |
156 | 156 | z = seg->z; |
157 | 157 | seg = seg->next; |
158 | 158 | while (seg) { |
159 | 159 | printf("!ZZ%d,%d,%d\n", units(seg->x), units(seg->y), |
160 | | units((seg->z-z_max)*z_scale)); |
161 | | d = hypot(x-seg->x, y-seg->y); |
162 | | txy = d/xy_speed; |
163 | | tz = fabs(z-seg->z)/z_speed; |
| 160 | units((seg->z - z_max) * z_scale)); |
| 161 | d = hypot(x - seg->x, y - seg->y); |
| 162 | txy = d / xy_speed; |
| 163 | tz = fabs(z - seg->z) / z_speed; |
164 | 164 | t += txy > tz ? txy : tz; |
165 | | d = hypot(d, z-seg->z); |
| 165 | d = hypot(d, z - seg->z); |
166 | 166 | s += d; |
167 | 167 | x = seg->x; |
168 | 168 | y = seg->y; |
... | ... | |
170 | 170 | seg = seg->next; |
171 | 171 | } |
172 | 172 | printf("PU\n"); |
173 | | d = z_max+z_clear-z; |
| 173 | d = z_max + z_clear - z; |
174 | 174 | s += d; |
175 | | t += d/V_MAX; |
176 | | z = z_max+z_clear; |
| 175 | t += d / V_MAX; |
| 176 | z = z_max + z_clear; |
177 | 177 | } |
178 | 178 | |
179 | 179 | printf("!MC0;!ZO0;!PZ0,0;PU0,0;IN\n"); |
180 | | d = -z+hypot(x, y); |
| 180 | d = -z + hypot(x, y); |
181 | 181 | s += d; |
182 | | t += d/V_MAX; |
| 182 | t += d / V_MAX; |
183 | 183 | fprintf(stderr, "Distance %.1f mm, time %.1f s\n", s, t); |
184 | 184 | } |
185 | 185 | |