不用三角函数实现的多点绕一个中心点旋转?

不用三角函数实现的多点绕一个中心点旋转?

李兴球Python不绕中心点旋转turtle
import time
import turtle

def godot(x,y):
turtle.goto(x,y)
turtle.dot(10,’red’)

def rotate(center,degree,*points):
“””一些点绕着center点旋转,每次旋转degree度
points是不定长参数,一个元组里面有一些点
“””
points = [B-center for B in points]
points = [C.rotate(degree) for C in points]
points = [C+center for C in points]
return points

turtle.penup()
turtle.goto(-100,-100)
turtle.begin_poly()
for i in range(5):
turtle.fd(100);turtle.dot(10,’red’)
turtle.left(72)
turtle.end_poly()
dots = list(turtle.get_poly())
dots.pop()
A = sum([x for x,y in dots])/len(dots),sum([y for x,y in dots])/len(dots)

成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

李兴球

李兴球的博客是Python创意编程原创博客