deep-learning-with-pytorch / dlwpt-code

Code for the book Deep Learning with PyTorch by Eli Stevens, Luca Antiga, and Thomas Viehmann.
https://www.manning.com/books/deep-learning-with-pytorch
4.69k stars 1.98k forks source link

xyz2irc() is not inverse of irc2xyz() #96

Open jiangjy1982 opened 2 years ago

jiangjy1982 commented 2 years ago

In this line, the inverse rotation needs to be left-multiplied rather than right-multiplied.

The correctness can be verified by the following code snippet:

import numpy as np
from util.util import irc2xyz, xyz2irc

origin_xyz = np.array([-100, -200, -300])
vxSize_xyz = np.array([1, 1, 2])
theta = np.radians(30)
c, s = np.cos(theta), np.sin(theta)
direction_a = np.array(((c, -s, 0), (s, c, 0), (0, 0, 1)))
xyz2irc([*irc2xyz([1, 2, 3], origin_xyz, vxSize_xyz, direction_a)], origin_xyz, vxSize_xyz, direction_a)
# Expect to return [1, 2, 3]