mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 04:23:55 +02:00
ptrude/: cleanup and addition of comments (WIP)
- arc.fig: corrected formula for 2t - path.c (corner): cleanup and added comments
This commit is contained in:
parent
d4c96f129d
commit
dcb1c7856a
@ -60,7 +60,7 @@ Single
|
|||||||
4 1 0 50 -1 18 18 0.0000 4 195 240 8505 7380 2t\001
|
4 1 0 50 -1 18 18 0.0000 4 195 240 8505 7380 2t\001
|
||||||
4 0 0 50 -1 18 18 0.0000 4 270 2085 9405 7200 (r-d)^2+u^2=r^2\001
|
4 0 0 50 -1 18 18 0.0000 4 270 2085 9405 7200 (r-d)^2+u^2=r^2\001
|
||||||
4 0 0 50 -1 18 18 0.0000 4 270 2610 9405 7650 (r-d)^2+v^2=(r+d)^2\001
|
4 0 0 50 -1 18 18 0.0000 4 270 2610 9405 7650 (r-d)^2+v^2=(r+d)^2\001
|
||||||
4 0 0 50 -1 18 18 0.0000 4 270 1530 9405 8100 2t = 2p+n*q\001
|
4 0 0 50 -1 18 18 0.0000 4 270 2400 9405 8100 2t = 2*(p+(n+1)*q)\001
|
||||||
4 0 0 50 -1 18 18 0.0000 4 210 915 4410 3105 ...+q+p\001
|
4 0 0 50 -1 18 18 0.0000 4 210 915 4410 3105 ...+q+p\001
|
||||||
4 1 0 50 -1 18 18 0.0000 4 210 180 4950 3555 q\001
|
4 1 0 50 -1 18 18 0.0000 4 210 180 4950 3555 q\001
|
||||||
4 1 0 50 -1 18 18 0.0000 4 210 180 4635 3870 q\001
|
4 1 0 50 -1 18 18 0.0000 4 210 180 4635 3870 q\001
|
||||||
|
@ -95,20 +95,38 @@ static const struct vertex *add_vertex(struct path *path, double x, double y,
|
|||||||
static const struct vertex *corner(struct path *path, const struct vertex *a,
|
static const struct vertex *corner(struct path *path, const struct vertex *a,
|
||||||
const struct vertex *b, const struct vertex *c, double r, double d)
|
const struct vertex *b, const struct vertex *c, double r, double d)
|
||||||
{
|
{
|
||||||
|
/* points to vectors */
|
||||||
double ax = b->x-a->x;
|
double ax = b->x-a->x;
|
||||||
double ay = b->y-a->y;
|
double ay = b->y-a->y;
|
||||||
double bx = c->x-b->x;
|
double bx = c->x-b->x;
|
||||||
double by = c->y-b->y;
|
double by = c->y-b->y;
|
||||||
|
|
||||||
|
/* vector length */
|
||||||
double aa = hypot(ax, ay);
|
double aa = hypot(ax, ay);
|
||||||
double bb = hypot(bx, by);
|
double bb = hypot(bx, by);
|
||||||
|
|
||||||
|
/* dot and cross product */
|
||||||
double dp = ax*bx+ay*by; /* a * b = a*b*cos 2t */
|
double dp = ax*bx+ay*by; /* a * b = a*b*cos 2t */
|
||||||
double cp = ax*by-ay*bx; /* |a x b| = a*b*sin 2t */
|
double cp = ax*by-ay*bx; /* |a x b| = a*b*sin 2t */
|
||||||
|
double dir = copysign(1, cp);
|
||||||
|
|
||||||
|
/* see corner.fig */
|
||||||
double dd; /* "d" of the given vectors */
|
double dd; /* "d" of the given vectors */
|
||||||
double tt, s;
|
double tt; /* tan t */
|
||||||
double t2, p, q, ang;
|
double s; /* distance between start of arc and corner */
|
||||||
double u, v;
|
double t2; /* angle, t*2 */
|
||||||
double f, x, y;
|
|
||||||
int n, i;
|
/* see arc.fig */
|
||||||
|
double p; /* half-angle of border side of border segment */
|
||||||
|
double q; /* half-angle of connecting segment */
|
||||||
|
double u; /* length of border side of border segment */
|
||||||
|
double v; /* half-length of connecting segment */
|
||||||
|
int n; /* number of connecting segments (0 if none) */
|
||||||
|
|
||||||
|
double f; /* scale factor; various uses */
|
||||||
|
double ang; /* current angle, for iteration */
|
||||||
|
double x, y; /* current position; for iteration */
|
||||||
|
int i; /* segment; for iteration */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* http://en.wikipedia.org/wiki/Dot_product
|
* http://en.wikipedia.org/wiki/Dot_product
|
||||||
@ -212,24 +230,18 @@ static const struct vertex *corner(struct path *path, const struct vertex *a,
|
|||||||
n = (int) ceil((t2-2*(p+q))/(2*q));
|
n = (int) ceil((t2-2*(p+q))/(2*q));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @@@ We should evenly distribute the slack, but that seems
|
* @@@ We should evenly distribute the slack and try to pick a
|
||||||
* difficult. For now, we just center the polygon.
|
* smaller value for d, but that seems difficult.
|
||||||
|
*
|
||||||
|
* For now, we just center the polygon.
|
||||||
*/
|
*/
|
||||||
q = (t2/2-p)/(n+1);
|
q = (t2/2-p)/(n+1);
|
||||||
|
|
||||||
double dir = copysign(1, cp);
|
|
||||||
#if 0
|
|
||||||
if (cp < 0) {
|
|
||||||
// t2 = -t2;
|
|
||||||
q = -q;
|
|
||||||
p = -p;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (n)
|
if (n)
|
||||||
ang = p+q;
|
ang = p+q;
|
||||||
else
|
else
|
||||||
ang = t2/2;
|
ang = t2/2;
|
||||||
|
|
||||||
u = tan(p)*(r-d);
|
u = tan(p)*(r-d);
|
||||||
v = tan(q)*(r-d);
|
v = tan(q)*(r-d);
|
||||||
f = (u+v)/aa;
|
f = (u+v)/aa;
|
||||||
|
Loading…
Reference in New Issue
Block a user