1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-04-21 12:27:27 +03:00

ptrude/: proper command-line handling; open -d for debug mode

This commit is contained in:
Werner Almesberger
2011-07-29 00:25:28 -03:00
parent 188cf9d9d4
commit 3dcd5cc9aa
4 changed files with 130 additions and 17 deletions

View File

@@ -15,6 +15,7 @@
#include <string.h>
#include <math.h>
#include "ptrude.h"
#include "path.h"
@@ -169,13 +170,16 @@ static const struct vertex *corner(struct path *path, const struct vertex *a,
*/
dd = hypot(r, s)-r;
fprintf(stderr, "a = (%g, %g)-(%g, %g) = (%g, %g); |a| = %g\n",
b->x, b->y, a->x, a->y, ax, ay, aa);
fprintf(stderr, "b = (%g, %g)-(%g, %g) = (%g, %g); |b| = %g\n",
c->x, c->y, b->x, b->y, bx, by, bb);
fprintf(stderr, "sin 2t = %g, cos 2t = %g, tan t = %g\n",
cp/aa/bb, dp/aa/bb, tt);
fprintf(stderr, "r = %g, d = %g, s = %g, dd = %g\n", r, d, s, dd);
if (debug) {
fprintf(stderr, "a = (%g, %g)-(%g, %g) = (%g, %g); |a| = %g\n",
b->x, b->y, a->x, a->y, ax, ay, aa);
fprintf(stderr, "b = (%g, %g)-(%g, %g) = (%g, %g); |b| = %g\n",
c->x, c->y, b->x, b->y, bx, by, bb);
fprintf(stderr, "sin 2t = %g, cos 2t = %g, tan t = %g\n",
cp/aa/bb, dp/aa/bb, tt);
fprintf(stderr, "r = %g, d = %g, s = %g, dd = %g\n",
r, d, s, dd);
}
/*
* We only know how to make a rounded corner if two vectors are
@@ -228,8 +232,9 @@ static const struct vertex *corner(struct path *path, const struct vertex *a,
q = acos((r-d)/(r+d));
fprintf(stderr, "t2 = %g, p(max) = %g, q(max) = %g\n",
deg(t2), deg(p), deg(q));
if (debug)
fprintf(stderr, "t2 = %g, p(max) = %g, q(max) = %g\n",
deg(t2), deg(p), deg(q));
/*
* Step 4: emit the starting point of the arc
@@ -279,8 +284,9 @@ static const struct vertex *corner(struct path *path, const struct vertex *a,
for (i = 0; i <= n; i++) {
x += f*ax*cos(ang-q)-dir*f*ay*sin(ang-q);
y += dir*f*ax*sin(ang-q)+f*ay*cos(ang-q);
fprintf(stderr, " %d/%d: %g %g @ %g\n", i, n,
x, y, deg(ang));
if (debug)
fprintf(stderr, " %d/%d: %g %g @ %g\n", i, n,
x, y, deg(ang));
add_vertex(path, x, y, 0, 0, NULL);
ang += 2*q;
f = (2*v)/aa;