def turn():
global epi_x, epi_y, p1, p2, p3, p4, rect
write_log()
teta = math.radians(window.spin_deg.value())
t_x = window.spin_turn_x.value()
t_y = window.spin_turn_y.value()
scene.clear()
rect_t = QPolygonF(4)
p1 = [t_x + (p1[0] - t_x) * math.cos(teta) + (p1[1] - t_y) * math.sin(teta),
t_y - (p1[0] - t_x) * math.sin(teta) + (p1[1] - t_y) * math.cos(teta)]
p2 = [t_x + (p2[0] - t_x) * math.cos(teta) + (p2[1] - t_y) * math.sin(teta),
t_y - (p2[0] - t_x) * math.sin(teta) + (p2[1] - t_y) * math.cos(teta)]
p3 = [t_x + (p3[0] - t_x) * math.cos(teta) + (p3[1] - t_y) * math.sin(teta),
t_y - (p3[0] - t_x) * math.sin(teta) + (p3[1] - t_y) * math.cos(teta)]
p4 = [t_x + (p4[0] - t_x) * math.cos(teta) + (p4[1] - t_y) * math.sin(teta),
t_y - (p4[0] - t_x) * math.sin(teta) + (p4[1] - t_y) * math.cos(teta)]
rect[0] = QPointF(p1[0], p1[1])
rect[1] = QPointF(p2[0], p2[1])
rect[2] = QPointF(p3[0], p3[1])
rect[3] = QPointF(p4[0], p4[1])
scene.addPolygon(rect, pen=p, brush=b)
l = len(epi_x)
for i in range(l):
x1 = t_x + (epi_x[i] - t_x) * math.cos(teta) + (epi_y[i] - t_y) * math.sin(teta)
y1 = t_y - (epi_x[i] - t_x) * math.sin(teta) + (epi_y[i] - t_y) * math.cos(teta)
epi_x[i] = x1
epi_y[i] = y1
scene.addLine(epi_x[i], epi_y[i], epi_x[i] + 0.01, epi_y[i] + 0.01, pen=p)
评论列表
文章目录