我已经得到了盒子的所有角落,但我不知道如何在Python处理中确定最小和最大x和y坐标
这是密码
add_library('peasycam')
def setup():
size(900, 800, P3D)
global camera
camera = PeasyCam(this, 0, 0, 0, 500)
def draw():
background(255, 255, 255)
lights()
directionalLight(0, 255, 0, 0.5, 1, 0.1)
pushMatrix()
fill(100, 100, 100)
box(100, 100, 100)
corner(50, 50, 50)
cx1 = screenX(0, 0, 0)
cy1 = screenY(0, 0, 0)
corner(-100, 0, 0)
cx2 = screenX(0, 0, 0)
cy2 = screenY(0, 0, 0)
corner(0, -100, 0)
cx3 = screenX(0, 0, 0)
cy3 = screenY(0, 0, 0)
corner(100, 0, 0)
cx4 = screenX(0, 0, 0)
cy4 = screenY(0, 0, 0)
corner(-100, 0, -100)
cx5 = screenX(0, 0, 0)
cy5 = screenY(0, 0, 0)
corner(100, 0, 0)
cx6 = screenX(0, 0, 0)
cy6 = screenY(0, 0, 0)
corner(0, 100, 0)
cx7 = screenX(0, 0, 0)
cy7 = screenY(0, 0, 0)
corner(-100, 0, 0)
cx8 = screenX(0, 0, 0)
cy8 = screenY(0, 0, 0)
popMatrix()
def corner(x, y, z):
translate(x, y, z)
box(10);
我做了很多研究,但没有找到更好的解决方案
提前感谢:)
我在下面附上了一个工作代码的Java实现。可以通过遍历PVector阵列来访问坐标。 我建议您在这个项目中使用Java,因为Processing.py目前有点不稳定,从长远来看,Java将被证明更加健壮。但是,如果您对Python更熟悉,那么坚持使用它就没有问题
希望这有帮助
相关问题 更多 >
编程相关推荐