• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Rotation Check

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 135 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    remus
    last edited by 27 Jan 2010, 16:16

    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 true if 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
    

    http://remusrendering.wordpress.com/

    1 Reply Last reply Reply Quote 0
    • C Offline
      Chris Fullmer
      last edited by 27 Jan 2010, 16:45

      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

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • R Offline
        remus
        last edited by 27 Jan 2010, 17:17

        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.)

        http://remusrendering.wordpress.com/

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement