Extract the first or third Euler angle from the two members of the matrix which are positive constant times its sine and cosine. Args: axis: Axis label "X" or "Y or "Z" for the angle we are finding. other_axis: Axis label "X" or "Y or "Z" for the middle axis in the
(
axis: str, other_axis: str, data, horizontal: bool, tait_bryan: bool
)
| 226 | |
| 227 | |
| 228 | def _angle_from_tan( |
| 229 | axis: str, other_axis: str, data, horizontal: bool, tait_bryan: bool |
| 230 | ) -> torch.Tensor: |
| 231 | """ |
| 232 | Extract the first or third Euler angle from the two members of |
| 233 | the matrix which are positive constant times its sine and cosine. |
| 234 | |
| 235 | Args: |
| 236 | axis: Axis label "X" or "Y or "Z" for the angle we are finding. |
| 237 | other_axis: Axis label "X" or "Y or "Z" for the middle axis in the |
| 238 | convention. |
| 239 | data: Rotation matrices as tensor of shape (..., 3, 3). |
| 240 | horizontal: Whether we are looking for the angle for the third axis, |
| 241 | which means the relevant entries are in the same row of the |
| 242 | rotation matrix. If not, they are in the same column. |
| 243 | tait_bryan: Whether the first and third axes in the convention differ. |
| 244 | |
| 245 | Returns: |
| 246 | Euler Angles in radians for each matrix in data as a tensor |
| 247 | of shape (...). |
| 248 | """ |
| 249 | |
| 250 | i1, i2 = {"X": (2, 1), "Y": (0, 2), "Z": (1, 0)}[axis] |
| 251 | if horizontal: |
| 252 | i2, i1 = i1, i2 |
| 253 | even = (axis + other_axis) in ["XY", "YZ", "ZX"] |
| 254 | if horizontal == even: |
| 255 | return torch.atan2(data[..., i1], data[..., i2]) |
| 256 | if tait_bryan: |
| 257 | return torch.atan2(-data[..., i2], data[..., i1]) |
| 258 | return torch.atan2(data[..., i2], -data[..., i1]) |
| 259 | |
| 260 | |
| 261 | def _index_from_letter(letter: str) -> int: |
no outgoing calls
no test coverage detected