kwea123 / nerf_pl

NeRF (Neural Radiance Fields) and NeRF in the Wild using pytorch-lightning
https://www.youtube.com/playlist?list=PLDV2CyUo4q-K02pNEyDr7DYpTQuka3mbV
MIT License
2.74k stars 483 forks source link

math explanation for rotate matrix axis change? #63

Closed zjjMaiMai closed 3 years ago

zjjMaiMai commented 3 years ago

hi, thanks for your great works! I am confused by this code: https://github.com/kwea123/nerf_pl/blob/422ce4bf5755aec5ca7ff4b24868b21f03145e37/datasets/llff.py#L198 In my opinion, what should be operated is axis=0 but not axis 1. and why we not change the translation in pose matrix?

kwea123 commented 3 years ago

poses have shape (N_images, 3, 4), we want to permute its rotation axes, so we change axis=2 (last axis). Translations are the camera positions in world coordinate, so it remains the same no matter how the cameras are rotated.

zjjMaiMai commented 3 years ago

poses have shape (N_images, 3, 4), we want to permute its rotation axes, so we change axis=2 (last axis).

i cant understand why shound we change last axis but not first axis. if we have a rotation matrix R_rdf form [right down front], and we need change to R_rub form [right up back]. we need flip Y-axis and Z-axis like this:

R_rub = np.diag([1, -1, -1]) @ R_rdf
# same as : R_rub = np.concatenate([R_rdf[0:1, ...], -R_rdf[1:3, ...]], axis=0)