diff --git a/gp2rml/gp2rml.c b/gp2rml/gp2rml.c index 5fbf857..b9697c8 100644 --- a/gp2rml/gp2rml.c +++ b/gp2rml/gp2rml.c @@ -60,7 +60,7 @@ static double z_max = -1e6; /* -1 km :) */ 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) \ @@ -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", units(seg->z-z_max), units(z_clear), 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 += z-z_max; - t += d/V_MAX; - t += (z-z_max)/z_speed; + s += z - z_max; + t += d / V_MAX; + t += (z - z_max) / z_speed; x = seg->x; y = seg->y; z = seg->z; seg = seg->next; while (seg) { printf("!ZZ%d,%d,%d\n", units(seg->x), units(seg->y), - units((seg->z-z_max)*z_scale)); - d = hypot(x-seg->x, y-seg->y); - txy = d/xy_speed; - tz = fabs(z-seg->z)/z_speed; + units((seg->z - z_max) * z_scale)); + d = hypot(x - seg->x, y - seg->y); + txy = d / xy_speed; + tz = fabs(z - seg->z) / z_speed; t += txy > tz ? txy : tz; - d = hypot(d, z-seg->z); + d = hypot(d, z - seg->z); s += d; x = seg->x; y = seg->y; @@ -170,16 +170,16 @@ static void output_paths(double z_clear, double xy_speed, double z_speed) seg = seg->next; } printf("PU\n"); - d = z_max+z_clear-z; + d = z_max + z_clear - z; s += d; - t += d/V_MAX; - z = z_max+z_clear; + t += d / V_MAX; + z = z_max + z_clear; } printf("!MC0;!ZO0;!PZ0,0;PU0,0;IN\n"); - d = -z+hypot(x, y); + d = -z + hypot(x, y); s += d; - t += d/V_MAX; + t += d / V_MAX; fprintf(stderr, "Distance %.1f mm, time %.1f s\n", s, t); }