0

因此,此维基百科页面向您展示了如何将 3d 空间中的点透视投影到 x/y 平面上。有谁知道如何在 y/z 平面上进行等效操作?这就是我现在正在做的事情(只是维基百科页面的东西。):

class Shape(object):
    ...
    def apply_perspective(self, camera_pos, orientation, viewer_pos):
        a, b, c = viewer_pos
        cx, cy, cz = map(cos, orientation)
        sx, sy, sz = map(sin, orientation)
        transformed_vertices = []
        append = transformed_vertices.append
        for v in self.vertices:
            x, y, z = v - camera_pos
            t1 = sz*y + cz*x
            t2 = cz*y - sz*x
            x_ = cy*t1 - sy*z
            t3 = cy*z + sy*t1
            y_ = sx*t3 + cx*t2
            z_ = cx*t3 - sx*t2
            t4 = c/z_
            newx = t4*x_ - a
            newy = t4*y_ - b
            append((newx, newy))
    return transformed_vertices

您可以在github repo中查看所有代码。特别是其中的文件是 shapes.py。

4

1 回答 1

0

我最终做了一个猜测,结果证明是正确的。我用过t4 = a/x_,newx = t4*y_ - bnewy = t4*z_ - c; 结果证明是正确的。我只是用代数!

于 2013-12-29T04:57:15.610 回答