mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-01-03 19:40:15 +02:00
drl2gp.c: added milling of slots (more to come)
This commit is contained in:
parent
49a42cb500
commit
32f36ccbc4
@ -137,9 +137,51 @@ static void header(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static double arc2angle(double arc, double r)
|
||||||
|
{
|
||||||
|
return acos(1-arc*arc/(r*r)/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void half_circle(double cx, double cy, double rx, double ry, double s)
|
||||||
|
{
|
||||||
|
double m[4];
|
||||||
|
double x = rx, y = ry, tmp;
|
||||||
|
double a;
|
||||||
|
|
||||||
|
m[0] = cos(s);
|
||||||
|
m[1] = -sin(s);
|
||||||
|
m[2] = -m[1];
|
||||||
|
m[3] = m[0];
|
||||||
|
|
||||||
|
for (a = 0; a < M_PI; a += s) {
|
||||||
|
printf("%f %f %f\n", cx+x, cy+y, -depth);
|
||||||
|
tmp = x*m[0]+y*m[1];
|
||||||
|
y = x*m[2]+y*m[3];
|
||||||
|
x = tmp;
|
||||||
|
}
|
||||||
|
printf("%f %f %f\n", cx-rx, cy-ry, -depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void slot(double xa, double ya, double xb, double yb, double d)
|
static void slot(double xa, double ya, double xb, double yb, double d)
|
||||||
{
|
{
|
||||||
|
double dx = xb-xa;
|
||||||
|
double dy = yb-ya;
|
||||||
|
double cr = d/2;
|
||||||
|
double tr = d0/2;
|
||||||
|
double s = arc2angle(MAX_STEP, cr);
|
||||||
|
double nx, ny;
|
||||||
|
double f;
|
||||||
|
|
||||||
assert(mill);
|
assert(mill);
|
||||||
|
f = (cr-tr)/hypot(dx, dy);
|
||||||
|
nx = -dy*f;
|
||||||
|
ny = dx*f;
|
||||||
|
|
||||||
|
half_circle(xa, ya, nx, ny, s);
|
||||||
|
half_circle(xb, yb, -nx, -ny, s);
|
||||||
|
printf("%f %f %f\n\n", xa+nx, ya+ny, -depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -147,7 +189,7 @@ static void circle(double cx, double cy, double d)
|
|||||||
{
|
{
|
||||||
double cr = d/2;
|
double cr = d/2;
|
||||||
double tr = d0/2;
|
double tr = d0/2;
|
||||||
double s = acos(1-MAX_STEP*MAX_STEP/(cr*cr)/2);
|
double s = arc2angle(MAX_STEP, cr);
|
||||||
double a;
|
double a;
|
||||||
|
|
||||||
assert(mill);
|
assert(mill);
|
||||||
|
Loading…
Reference in New Issue
Block a user