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

cameo/shape.c: removed global "path" variable (where did that madness come from ?)

This commit is contained in:
Werner Almesberger 2011-09-05 05:49:23 -03:00
parent a42a18fef3
commit a67d0b447e

View File

@ -17,17 +17,14 @@
#include "shape.h" #include "shape.h"
static struct path *path;
static double arc2angle(double arc, double r) static double arc2angle(double arc, double r)
{ {
return acos(1-arc*arc/(r*r)/2); return acos(1-arc*arc/(r*r)/2);
} }
static void half_circle(double cx, double cy, double rx, double ry, double z, static void half_circle(struct path *path,
double s) double cx, double cy, double rx, double ry, double z, double s)
{ {
double m[4]; double m[4];
double x = rx, y = ry, tmp; double x = rx, y = ry, tmp;
@ -51,6 +48,7 @@ static void half_circle(double cx, double cy, double rx, double ry, double z,
struct path *slot(double xa, double ya, double xb, double yb, double z, struct path *slot(double xa, double ya, double xb, double yb, double z,
double sr, double tr, double step, const char *id) double sr, double tr, double step, const char *id)
{ {
struct path *path;
double dx = xb-xa; double dx = xb-xa;
double dy = yb-ya; double dy = yb-ya;
double s = arc2angle(step, sr); double s = arc2angle(step, sr);
@ -66,8 +64,8 @@ struct path *slot(double xa, double ya, double xb, double yb, double z,
nx = -dy*f; nx = -dy*f;
ny = dx*f; ny = dx*f;
half_circle(xa, ya, nx, ny, z, s); half_circle(path, xa, ya, nx, ny, z, s);
half_circle(xb, yb, -nx, -ny, z, s); half_circle(path, xb, yb, -nx, -ny, z, s);
path_add(path, xa+nx, ya+ny, z); path_add(path, xa+nx, ya+ny, z);
} }
return path; return path;
@ -77,6 +75,7 @@ struct path *slot(double xa, double ya, double xb, double yb, double z,
struct path *circle(double cx, double cy, double cz, double cr, double tr, struct path *circle(double cx, double cy, double cz, double cr, double tr,
double step, const char *id) double step, const char *id)
{ {
struct path *path;
double s = arc2angle(step, cr); double s = arc2angle(step, cr);
double a; double a;