Here's how to model the spinning and flipping t-handle in space (the Dzhanibekov Effect). In this case, I just use three masses and springs (numerical calculation) to show that it flips.
t-handle in space
• Dancing T-handle in zero-g, HD
Explanation from Veritasium
• The Bizarre Behavior of Rotating Bodies
Code
https://trinket.io/glowscript/0f3b129170