sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [Code]Transformation_Extensions 20110209

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 1.5k 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      transformation.extensions.rb (c) TIG 2009-2011

      From original ideas by TBD and others ? ### TIG 20091010

      The euler rotation ideas from Dave Burdick 20100324

      It extends the methods for Geom::Transformation...

      The built-in method "object.transformation.origin" return a point3d

      that is the object's origin/insertion: the new method

      object.transformation.getX etc returns the X location of the

      object [or Y or Z].

      The setX(x) resets the X value of the object [or Y or Z]: it

      returns a new transformation that can then be used to reset the

      original transformation; thus:

      object.transformation=object.transformation.setX(another_object.transformation.getX)

      - here it makes the object's X = another_object's X ;

      it also could be given a float, e.g. 12.345 or a 'variable'...

      The object.transformation.scaleX etc returns the scale on that axis.

      The object.transformation.rotX etc returns the rotation on that axis

      in radians: use ... .rotX.radians to get it in degrees...

      It uses different names to TBD's, e.g. 'rotZ' instead of 'zrot' etc.

      Note the capitalization... this is because some 'compiled scripts'

      use 'rotz' already etc - [and they return the rotation in degrees!]

      object.transformation.rotXYZ

      returns a 3 item array giving the rotations in x/y/z

      object.transformation.rot_a

      returns an 11 item array of the transformation's rotation/scaling

      - it can be used to extract some data more easily or as below...

      object.transformation=object.transformation.rotation_from_rot_a(another_object.transformation.rot_a)

      this applies another_object's 'rot_a' to change the object.

      object.transformation=object.transformation.rotation_from(another_object.transformation)

      this applies another_object's rotation/scaling to the object.

      it returns a new transformation that can then be used to reset the original...

      object.transformation=object.transformation.origin_from(another_object.transformation)

      this applies another_object's origin/location to the object.

      it returns a new transformation that can then be used to reset the original...

      object.transformation=object.transformation.rotation_from_xyz([xrot,yrot,zrot])

      this applies a 3 item array of x/y/z rotations about the model's x/y/z-axes,

      this could also be the array returned by rotXYZ.

      it returns a new transformation that can then be used to reset the original...

      object.transformation=object.transformation.rotation_from_xyz_locally([xrot,yrot,zrot])

      this applies a 3 item array of x/y/z rotations about the objects's x/y/z-axes,

      this could also be the array returned by rotXYZ.

      it returns a new transformation that can then be used to reset the original...

      updated 20110209 TIG

      ###transformation_extensions.rb

      TIG

      1 Reply Last reply Reply Quote 0
      • T Offline
        tomasz
        last edited by

        Thanks TIG. They may be handy one day πŸ˜„

        Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          I've updated this code as it was well out of date and new versions drifting around on the forums has typos etc - this is the definitive version [as of today at least πŸ˜’ ]

          TIG

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

          Advertisement