Created
April 4, 2024 23:17
-
-
Save orangeduck/e1d70fdbfcdcf327850b7b39a36543c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quat_from_xform(ts): | |
return quat_normalize( | |
torch.where((ts[...,2,2] < 0.0)[...,None], | |
torch.where((ts[...,0,0] > ts[...,1,1])[...,None], | |
torch.cat([ | |
(ts[...,2,1]-ts[...,1,2])[...,None], | |
(1.0 + ts[...,0,0] - ts[...,1,1] - ts[...,2,2])[...,None], | |
(ts[...,1,0]+ts[...,0,1])[...,None], | |
(ts[...,0,2]+ts[...,2,0])[...,None]], dim=-1), | |
torch.cat([ | |
(ts[...,0,2]-ts[...,2,0])[...,None], | |
(ts[...,1,0]+ts[...,0,1])[...,None], | |
(1.0 - ts[...,0,0] + ts[...,1,1] - ts[...,2,2])[...,None], | |
(ts[...,2,1]+ts[...,1,2])[...,None]], dim=-1)), | |
torch.where((ts[...,0,0] < -ts[...,1,1])[...,None], | |
torch.cat([ | |
(ts[...,1,0]-ts[...,0,1])[...,None], | |
(ts[...,0,2]+ts[...,2,0])[...,None], | |
(ts[...,2,1]+ts[...,1,2])[...,None], | |
(1.0 - ts[...,0,0] - ts[...,1,1] + ts[...,2,2])[...,None]], dim=-1), | |
torch.cat([ | |
(1.0 + ts[...,0,0] + ts[...,1,1] + ts[...,2,2])[...,None], | |
(ts[...,2,1]-ts[...,1,2])[...,None], | |
(ts[...,0,2]-ts[...,2,0])[...,None], | |
(ts[...,1,0]-ts[...,0,1])[...,None]], dim=-1)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment