2012-05-05 03:40:55 +03:00
|
|
|
#!/bin/sh
|
|
|
|
. ./Common
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
tst "outer offset" <<EOF
|
|
|
|
struct p2d *p = p2d_new();
|
|
|
|
struct p2d *q;
|
|
|
|
|
|
|
|
p2d_append(p, v2d_new(0, 0));
|
|
|
|
p2d_append(p, v2d_new(2, 0));
|
|
|
|
p2d_append(p, v2d_new(2, 1));
|
|
|
|
p2d_append(p, v2d_new(0, 1));
|
|
|
|
p2d_close(p);
|
|
|
|
q = p2d_offset(p, 0.5);
|
|
|
|
p2d_write_gnuplot(stdout, p2d_reverse(q->next));
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
-0.5 -0.5
|
|
|
|
2.5 -0.5
|
|
|
|
2.5 1.5
|
|
|
|
-0.5 1.5
|
|
|
|
-0.5 -0.5
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
tst "inner offset" <<EOF
|
|
|
|
struct p2d *p = p2d_new();
|
|
|
|
struct p2d *q;
|
|
|
|
|
|
|
|
p2d_append(p, v2d_new(0, 0));
|
|
|
|
p2d_append(p, v2d_new(2, 0));
|
|
|
|
p2d_append(p, v2d_new(2, 1));
|
|
|
|
p2d_append(p, v2d_new(0, 1));
|
|
|
|
p2d_close(p);
|
|
|
|
q = p2d_offset(p, -0.1);
|
|
|
|
p2d_write_gnuplot(stdout, q);
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
0.1 0.1
|
|
|
|
1.9 0.1
|
|
|
|
1.9 0.9
|
|
|
|
0.1 0.9
|
|
|
|
0.1 0.1
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2012-05-08 04:12:21 +03:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
tst "inner offset, polygon cw" <<EOF
|
|
|
|
struct p2d *p = p2d_new();
|
|
|
|
struct p2d *q;
|
|
|
|
|
|
|
|
p2d_append(p, v2d_new(0, 0));
|
|
|
|
p2d_append(p, v2d_new(0, 1));
|
|
|
|
p2d_append(p, v2d_new(2, 1));
|
|
|
|
p2d_append(p, v2d_new(2, 0));
|
|
|
|
p2d_close(p);
|
|
|
|
q = p2d_offset(p, -0.1);
|
|
|
|
p2d_write_gnuplot(stdout, q);
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
0.1 0.1
|
|
|
|
1.9 0.1
|
|
|
|
1.9 0.9
|
|
|
|
0.1 0.9
|
|
|
|
0.1 0.1
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2012-05-05 03:40:55 +03:00
|
|
|
###############################################################################
|