MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / getWorld2View2_torch

Function getWorld2View2_torch

utils/graphics_utils.py:51–69  ·  view source on GitHub ↗
(R, t, translate=torch.tensor([0.0, 0.0, 0.0]), scale=1.0)

Source from the content-addressed store, hash-verified

49 return np.float32(Rt)
50
51def getWorld2View2_torch(R, t, translate=torch.tensor([0.0, 0.0, 0.0]), scale=1.0):
52 translate = torch.tensor(translate, dtype=torch.float32)
53
54 # Initialize the transformation matrix
55 Rt = torch.zeros((4, 4), dtype=torch.float32)
56 Rt[:3, :3] = R.t() # Transpose of R
57 Rt[:3, 3] = t
58 Rt[3, 3] = 1.0
59
60 # Compute the inverse to get the camera-to-world transformation
61 C2W = torch.linalg.inv(Rt)
62 cam_center = C2W[:3, 3]
63 cam_center = (cam_center + translate) * scale
64 C2W[:3, 3] = cam_center
65
66 # Invert again to get the world-to-view transformation
67 Rt = torch.linalg.inv(C2W)
68
69 return Rt
70
71def getProjectionMatrix(znear, zfar, fovX, fovY):
72 tanHalfFovY = math.tan((fovY / 2))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected