|
138 | 138 | " matrix = torch.einsum(\"bij, bjk -> bik\", T.matrix, self.matrix)\n", |
139 | 139 | " return RigidTransform(matrix)\n", |
140 | 140 | "\n", |
141 | | - " def convert(self, parameterization, convention=None):\n", |
| 141 | + " def convert(self, parameterization, convention=None, degrees=False):\n", |
142 | 142 | " translation = -self.inverse().translation\n", |
143 | 143 | " if parameterization == \"axis_angle\":\n", |
144 | 144 | " rotation = matrix_to_axis_angle(self.matrix[..., :3, :3])\n", |
145 | 145 | " elif parameterization == \"euler_angles\":\n", |
146 | 146 | " rotation = matrix_to_euler_angles(self.matrix[..., :3, :3], convention)\n", |
| 147 | + " if degrees:\n", |
| 148 | + " rotation = rotation / torch.pi * 180\n", |
147 | 149 | " elif parameterization == \"matrix\":\n", |
148 | 150 | " rotation = self.matrix[..., :3, :3]\n", |
149 | 151 | " elif parameterization == \"quaternion\":\n", |
|
243 | 245 | "outputs": [], |
244 | 246 | "source": [ |
245 | 247 | "#| export\n", |
246 | | - "def convert(*args, parameterization, convention=None) -> RigidTransform:\n", |
| 248 | + "def convert(*args, parameterization, convention=None, degrees=False) -> RigidTransform:\n", |
247 | 249 | " if parameterization == \"euler_angles\" and convention is None:\n", |
248 | 250 | " raise ValueError(\n", |
249 | 251 | " \"convention for Euler angles must be specified as a 3 letter combination of [X, Y, Z]\"\n", |
|
256 | 258 | " matrix = make_matrix(rotmat, camera_center)\n", |
257 | 259 | " elif parameterization == \"euler_angles\":\n", |
258 | 260 | " rotation, translation = args\n", |
| 261 | + " if degrees:\n", |
| 262 | + " rotation = rotation / 180 * torch.pi\n", |
259 | 263 | " rotmat = euler_angles_to_matrix(rotation, convention)\n", |
260 | 264 | " camera_center = torch.einsum(\"bij, bj -> bi\", rotmat, translation)\n", |
261 | 265 | " matrix = make_matrix(rotmat, camera_center)\n", |
|
0 commit comments