【发布时间】:2016-05-23 07:01:40
【问题描述】:
如何通过给出高度、宽度和深度以编程方式(python)绘制矩形(斜投影视图)。
【问题讨论】:
-
您通常应该展示您研究过的内容以及您在代码中遇到的具体问题。
标签: python math diagram projection
如何通过给出高度、宽度和深度以编程方式(python)绘制矩形(斜投影视图)。
【问题讨论】:
标签: python math diagram projection
看看 Python 的 turtle 模块,here is the v3.3 documentation。除了高度、宽度和深度之外,您还需要考虑投影的角度——我认为这通常是 30/45 度。
让您开始...adapting code by Y. Daniel Liang。
import turtle
w = 100
h = 50
d = 20
angle = 30
def drawRectangle(width, height):
turtle.right(90)
turtle.forward(height)
turtle.right(90)
turtle.forward(width)
turtle.right(90)
turtle.forward(height)
turtle.right(90)
turtle.forward(width)
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
drawRectangle(w, h)
turtle.left(angle)
turtle.forward(d)
turtle.right(angle)
drawRectangle(w, h)
【讨论】: