That was a bit older example, and I was going for a certain look but as you pointed out it doesn't move accurately. I'd probably need to figure out the formulas again to account for that. Probably simpler to use the other capx though.
Like in that video the box is rotated around a corner and every time the box lands on an edge (every 90 degrees) it changes which corner to rotate around.