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

Function getOrthProjectionMatrix

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

Source from the content-addressed store, hash-verified

72 return P
73
74def getOrthProjectionMatrix(znear, zfar, fovX, fovY):
75 # Calculate the width and height of the orthographic view volume
76 # tanHalfFovY = math.tan(fovY / 2)
77 # tanHalfFovX = math.tan(fovX / 2)
78 znear, zfar = 0., 1.0
79 top = 1
80 bottom = -top
81 right = 1
82 left = -right
83
84 # Create an identity matrix
85 P = torch.zeros(4, 4)
86
87 z_sign = 1.0 # Adjust this based on handedness (e.g., 1.0 for right-handed, -1.0 for left-handed)
88
89 # Fill in the orthographic projection matrix
90 P[0, 0] = 2.0 / (right - left)
91 P[1, 1] = 2.0 / (top - bottom)
92 P[2, 2] = -2.0 * z_sign / (zfar - znear)
93 P[0, 3] = -(right + left) / (right - left)
94 P[1, 3] = -(top + bottom) / (top - bottom)
95 P[2, 3] = -(zfar + znear) / (zfar - znear)
96 P[3, 3] = 1.0
97
98 return P
99
100def getProjectionMatrixCenterShift(znear, zfar, cx, cy, fl_x, fl_y, w, h):
101 top = cy / fl_y * znear

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected