我正在使用旋转矩阵、弱透视方程和自定义海龟包装器的组合来制作一个3D海龟包装器(这是一个玩具项目,看看我是否可以在没有numpy的情况下也使用海龟的情况下完成3D)
为了澄清这一点,我不必复制和粘贴代码,pix(point, update)
在屏幕上标记一个小方形海龟来显示顶点。setup()
使其tracer(0,0)
,然后shapesize(1 / 20, 1 / 20)
,ht
,最后penup()
refresh()只使用update()
在这里:
def vertdata(crt): #CRT stands for Coord-Rotation-Transformation. I took
#transformation out for now, because those values are 0
#for this example.
vert = [crt[0][0],crt[0][1],crt[0][2]]
rotation = [crt[1][0],crt[1][1],crt[1][2]]
return rotate(vert, rotation)
def vertex(point, upd):
data = vertdata(point)
pix([((data[0] * 2) / ((data[2] / 15) - 15) * 10), ((data[1] * 2) / ((data[2] / 15) - 15) * 10)], upd)
setup(100, 1000, 1000)
for x in range(3600):
clear()
vertex(
[[10,-10,10],
[45,45,x]],
False
)
vertex(
[[-10,-10,10],
[45,45,x]],
False
)
vertex(
[[10,10,10],
[45,45,x]],
False
)
vertex(
[[-10,10,10],
[45,45,x]],
False
)
vertex(
[[10,-10,-10],
[45,45,x]],
False
)
vertex(
[[-10,-10,-10],
[45,45,x]],
False
)
vertex(
[[10,10,-10],
[45,45,x]],
False
)
vertex(
[[-10,10,-10],
[45,45,x]],
False
)
refresh()
#Sorry about the long code. I don't really think I can simplify this any more.
有什么问题吗?Z轴上的旋转扭曲。立方体会拉伸和变形。很久以前,我在scratch中也做了同样的事情(很久以前),我把这些公式输入python,因为我知道它们是有效的。(所以是的,他们工作)我不能发现问题,也许你们中的一个可以?这是我最后的选择。这里有一张图片可以帮助你。对不起,我现在用手机,因为我不能再使用电脑了,所以我不能给出失真的图片。你知道吗
我猜错了,但我找不到。你知道吗
我把它修好了,这是我方程式中的一个输入错误。 另外,我忘了在文章中包含旋转方程函数。你知道吗
相关问题 更多 >
编程相关推荐