MCPcopy Create free account
hub / github.com/DSL-Lab/StreamSplat / getProjectionMatrix

Function getProjectionMatrix

utils/graphics_utils.py:52–72  ·  view source on GitHub ↗
(znear, zfar, fovX, fovY)

Source from the content-addressed store, hash-verified

50 return np.float32(Rt)
51
52def getProjectionMatrix(znear, zfar, fovX, fovY):
53 tanHalfFovY = math.tan((fovY / 2))
54 tanHalfFovX = math.tan((fovX / 2))
55
56 top = tanHalfFovY * znear
57 bottom = -top
58 right = tanHalfFovX * znear
59 left = -right
60
61 P = torch.zeros(4, 4)
62
63 z_sign = 1.0
64
65 P[0, 0] = 2.0 * znear / (right - left)
66 P[1, 1] = 2.0 * znear / (top - bottom)
67 P[0, 2] = (right + left) / (right - left)
68 P[1, 2] = (top + bottom) / (top - bottom)
69 P[3, 2] = z_sign
70 P[2, 2] = z_sign * zfar / (zfar - znear)
71 P[2, 3] = -(zfar * znear) / (zfar - znear)
72 return P
73
74def getOrthProjectionMatrix(znear, zfar, fovX, fovY):
75 # Calculate the width and height of the orthographic view volume

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected