因此,我知道如何制作三棱锥,但是我试图弄清楚如何使其几乎像一个轮子一样(如何基本上制造辐条)。如果可以的话,那就太好了!
import turtle
turtle.hideturtle()
turtle.up()
turtle.goto(0,150)
turtle.down()
numberOfSides = 30
lengthOfSide = 50
exteriorAngle = 360/numberOfSides
for i in range(numberOfSides):
turtle.forward(lengthOfSide)
turtle.right(exteriorAngle)
我希望它看起来像什么:
答案 0 :(得分:0)
尝试以下代码:
import turtle
import math
num=30
A=turtle.position()
side=50
x=(side/2)/math.sin(math.radians(180/num))
#x contains the length of one spoke of wheel
ext=90+(180/num)
turtle.setheading(0)
for i in range(num):
turtle.forward(x)
turtle.left(ext)
turtle.forward(side)
turtle.left(ext)
turtle.forward(x)
turtle.setheading((i+1)*(360/num))
# the loop makes one triangle of polygon
答案 1 :(得分:0)
这是我的解决方法:
from turtle import *
circle(100)
left(90)
speed(10000000)
fd(100)
for i in range(60):
fd(100)
back(100)
left(12)
这会吸引31条辐条,所以算出30条辐条,使我成为59。
图片:
答案 2 :(得分:0)
尝试以最少的附加代码从您所要到达的地方:
import turtle
numberOfSides = 30
lengthOfSide = 75
exteriorAngle = 360 / numberOfSides
turtle.hideturtle()
turtle.sety(-lengthOfSide)
for i in range(numberOfSides):
turtle.circle(lengthOfSide, extent=exteriorAngle, steps=1)
position = turtle.position()
turtle.goto(0, 0)
turtle.setposition(position)
turtle.done()