Rotation Check
-
An interesting feature of a transformation matrix is that its determinant will always be 1 if it is a rotation or combination of rotations so i wrote this little snippet to test whether a given transformation matrix consists solely of a combination of rotations.
Probably not much practical use but someone might find use for it somewhere.
A little word of warning, it'll also return
trueif you just input the identity matrix (which i suppose is technically a rotation of 0 degrees.)def rotation_check(trans) arr = trans.to_a a1 = arr[0] a2 = arr[1] a3 = arr[2] a4 = arr[4] a5 = arr[5] a6 = arr[6] a7 = arr[8] a8 = arr[9] a9 = arr[10] det_arr = a1*(a5*a9-a6*a8)-a2*(a4*a9-a7*a6)+a3*(a4*a8-a7*a5) if det_arr == 1 and arr[14] ==0 and arr[13] == 0 and arr[12] == 0 true else false end#if end#def -
if the transformation is moved off 0,0,0, it will not return 1 yeah? And if the comp has been scaled or skewed it does not return 1, right? Those are the things it checks for more or less, right?
Chris
-
No, it will not return true in any of those cases. Having said that, if i was less lazy it would be fairly trivial to get it to check for translations and 'skews, scales and rotations' (although not each separately.)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement