mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-22 23:59:34 +02:00
gp2rml: improved distance calculation; corrected compiler invocation
This commit is contained in:
parent
fb117b20e5
commit
76b1b3e42e
@ -16,7 +16,7 @@ MAIN=gp2rml
|
||||
OBJS=gp2rml.o
|
||||
|
||||
CFLAGS = -g -Wall -Wshadow
|
||||
LDFLAGS = -lm
|
||||
LDLIBS = -lm
|
||||
|
||||
$(MAIN): $(OBJS)
|
||||
# $(CC) $(LDFLAGS) -o $(MAIN) $(OBJS)
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gp2rml.c - Convert from gnuplot to RML
|
||||
*
|
||||
* Written 2010-2011 by Werner Almesberger
|
||||
* Copyright 2010-2011 Werner Almesberger
|
||||
* Written 2010-2012 by Werner Almesberger
|
||||
* Copyright 2010-2012 Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -131,6 +131,7 @@ static void output_paths(double z_clear, double xy_speed, double z_speed)
|
||||
const struct segment *seg;
|
||||
double x = 0, y = 0, z = 0;
|
||||
double d, s = 0, t = 0;
|
||||
double txy, tz;
|
||||
|
||||
printf("IN;!MC1;PA\n");
|
||||
printf("!ZO%d;!PZ0,%d;PU\n", units(z_max), units(z_clear));
|
||||
@ -153,9 +154,12 @@ static void output_paths(double z_clear, double xy_speed, double z_speed)
|
||||
while (seg) {
|
||||
printf("!ZZ%d,%d,%d\n", units(seg->x), units(seg->y),
|
||||
units(seg->z-z_max));
|
||||
d = hypot(hypot(x-seg->x, y-seg->y), z-seg->z);
|
||||
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);
|
||||
s += d;
|
||||
t += d/z_speed;
|
||||
x = seg->x;
|
||||
y = seg->y;
|
||||
z = seg->z;
|
||||
|
Loading…
Reference in New Issue
Block a user