Example #1
0
point_1 = [[50, 50], [20, 55], [10, 35], [20, 10], [40, 10], [55, 25]]
point_2 = [[30, 30], [40, 30], [30, 40]]

# 多边形顶点数
POINTNUM_1 = len(point_1)
POINTNUM_2 = len(point_2)
POINTNUM = POINTNUM_1 + POINTNUM_2

# 偏置距离
d = 4
# 扫描线间隔距离
path_width = 6 * 10
# 多边形顺时针旋转
b = max(point_1[1])  # 绕(b,b)旋转,b为y轴最大值

point_offset = Pol.Shrink(d, *point_1)
print('point_offset', point_offset)


# 定义边的结构
class XET:
    def __init__(self, x=0.0, dx=0.0, ymax=0):
        self.x = x
        self.dx = dx
        self.ymax = ymax
        self.next = None


class Point:
    def __init__(self, x, y):
        self.x = x
point_1 = point
print('point_1', point_1)

# 偏置距离
d = 3
d_ = d * (2 + 1)
point_ = []
# 扫描线间隔距离
path_width = 4 * 10  # 全部数据扩大10倍,画图时在缩小即可,扫描线间隔是4(原因是程序中i不能产生浮点数)
# 多边形顺时针旋转
b = max(point_1[1])  # 绕(b,b)旋转,b为y轴最大值,步进旋转法中用到,在此程序中不能出现坐标y为负数,所以取较大者为旋转中心点

# 调用偏置程序 (import Polygon_offset as Pol)
for x in range(0, d_, d):
    print(x)
    a = Pol.Shrink(x, *point_1)
    point_.append(a)

point_offset = point_[int((d_/d)-1)]

# 多边形顶点数
POINTNUM_1 = len(point_offset)
POINTNUM = POINTNUM_1


# 定义边的结构
class XET:
    def __init__(self, x=0.0, dx=0.0, ymax=0):
        self.x = x
        self.dx = dx
        self.ymax = ymax