(R, t, translate=torch.tensor([0.0, 0.0, 0.0]), scale=1.0)
| 49 | return np.float32(Rt) |
| 50 | |
| 51 | def 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 | |
| 71 | def getProjectionMatrix(znear, zfar, fovX, fovY): |
| 72 | tanHalfFovY = math.tan((fovY / 2)) |
nothing calls this directly
no outgoing calls
no test coverage detected