π’ PlaceMaker | 25% off for February including new Google Earth data imports!
Learn more
[Code]Transformation_Extensions 20110209
-
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
-
Thanks TIG. They may be handy one day
-
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
]
Advertisement