1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 03:22:25 +02:00

gp2rml/gp2rml.c: add spaces around operators

This commit is contained in:
Werner Almesberger 2015-05-22 10:49:29 -03:00
parent ea11b88bee
commit efe5f38eb4

View File

@ -60,7 +60,7 @@ static double z_max = -1e6; /* -1 km :) */
static double z_scale = 1; /* < 1: compress; > 1: stretch */ static double z_scale = 1; /* < 1: compress; > 1: stretch */
#define units(mm) ((int) round((mm)*40.0)) #define units(mm) ((int) round((mm) * 40.0))
#define alloc_type(t) \ #define alloc_type(t) \
@ -146,23 +146,23 @@ static void output_paths(double z_clear, double xy_speed, double z_speed)
printf("!PZ%d,%d;PA%d,%d;PD\n", printf("!PZ%d,%d;PA%d,%d;PD\n",
units(seg->z-z_max), units(z_clear), units(seg->z-z_max), units(z_clear),
units(seg->x), units(seg->y)); units(seg->x), units(seg->y));
d = hypot(x-seg->x, y-seg->y); d = hypot(x - seg->x, y - seg->y);
s += d; s += d;
s += z-z_max; s += z - z_max;
t += d/V_MAX; t += d / V_MAX;
t += (z-z_max)/z_speed; t += (z - z_max) / z_speed;
x = seg->x; x = seg->x;
y = seg->y; y = seg->y;
z = seg->z; z = seg->z;
seg = seg->next; seg = seg->next;
while (seg) { while (seg) {
printf("!ZZ%d,%d,%d\n", units(seg->x), units(seg->y), printf("!ZZ%d,%d,%d\n", units(seg->x), units(seg->y),
units((seg->z-z_max)*z_scale)); units((seg->z - z_max) * z_scale));
d = hypot(x-seg->x, y-seg->y); d = hypot(x - seg->x, y - seg->y);
txy = d/xy_speed; txy = d / xy_speed;
tz = fabs(z-seg->z)/z_speed; tz = fabs(z - seg->z) / z_speed;
t += txy > tz ? txy : tz; t += txy > tz ? txy : tz;
d = hypot(d, z-seg->z); d = hypot(d, z - seg->z);
s += d; s += d;
x = seg->x; x = seg->x;
y = seg->y; y = seg->y;
@ -170,16 +170,16 @@ static void output_paths(double z_clear, double xy_speed, double z_speed)
seg = seg->next; seg = seg->next;
} }
printf("PU\n"); printf("PU\n");
d = z_max+z_clear-z; d = z_max + z_clear - z;
s += d; s += d;
t += d/V_MAX; t += d / V_MAX;
z = z_max+z_clear; z = z_max + z_clear;
} }
printf("!MC0;!ZO0;!PZ0,0;PU0,0;IN\n"); printf("!MC0;!ZO0;!PZ0,0;PU0,0;IN\n");
d = -z+hypot(x, y); d = -z + hypot(x, y);
s += d; s += d;
t += d/V_MAX; t += d / V_MAX;
fprintf(stderr, "Distance %.1f mm, time %.1f s\n", s, t); fprintf(stderr, "Distance %.1f mm, time %.1f s\n", s, t);
} }