My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google SketchUp Ruby API

Transformation

class

Parent: Object

Introduction

SketchUp 6.0+

Transformations are a standard construct in the 3D world for representing the position, rotation, and sizing of a given entity. In the SketchUp world, Components and Groups have a .transformation method that reports their current state and various methods (.move!, transformation=, etc.) that allow them to be manipulated.

Use of the transformation class requires a knowledge of geometrical transformations in 3 dimensions which is covered extensively on the Internet.

Methods

Transformation.*SketchUp 6.0+

The * method is used to do matrix multiplication using the Transform.

Arguments:

point1
A Point3d, Vector3d, or Transformation object.

Returns:

transformation
a new Transformation object.
 point = Geom::Point3d.new 10,20,30
 point2 = Geom::Point3d.new 2,2,2
 t = Geom::Transformation.new point
 point3 = t * point2
 UI.messagebox point3

Transformation.axesSketchUp 6.0+

The axes method creates a Transformation that goes from world coordinates to an arbitrary coordinate system defined by an origin and three axis vectors.

Arguments:

origin
A Point3d object.
xaxis
A Vector3d object.
yaxis
A Vector3d object.
zaxis
A Vector3d object.

Returns:

transformation
a new Transformation object
 t = Geom::Transformation.axes origin, xaxis, yaxis, zaxis
 UI.messagebox t

Transformation.cloneSketchUp 6.0+

The clone method is used to create a copy of a transformation.

Returns:

transformation2
a new Transformation object (clone of transformation1)
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 t2 = t.clone
 UI.messagebox t2

Transformation.identity?SketchUp 6.0+

The identity? method is used to determine if a transformation is the identity transform.

Returns:

status
true if the transformation is the identity transform, false if it is not the identity transform.
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 status = t.identity?
 UI.messagebox status

Transformation.interpolateSketchUp 6.0+

The interpolate method is used to create a new transformation that is the result of interpolating between two other transformations.

Parameter is a percent (between 0 and 1) that identifies whether to favor transformation1 or transformation2.

Arguments:

transform1
A Transformation object.
transform2
A Transformation object.
parameter
A value between 0 and 1 (see comments).

Returns:

transformation3
the new Transformation object
 origin = Geom::Point3d.new 0,0,0
 x = Geom::Vector3d.new 0,1,0
 y = Geom::Vector3d.new 1,0,0
 z = Geom::Vector3d.new 0,0,1
 point = Geom::Point3d.new 10,20,30
 t1 = Geom::Transformation.new point
 t2 = Geom::Transformation.axes origin, x, y, z
 t3 = Geom::Transformation.interpolate t1, t2, 25
 UI.messagebox t3

Transformation.inverseSketchUp 6.0+

The inverse method is used to retrieve the inverse of a transformation.

Returns:

transformation2
the Transformation object at its inverse.
 transformation2 = transformation1.inverse

Transformation.invert!SketchUp 6.0+

The invert! method sets the transformation to its inverse.

Returns:

transformation
the Transformation object at its inverse.
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 t2 = t.invert!
 UI.messagebox t2

Transformation.newSketchUp 6.0+

The new method is used to create a new transformation.

You can use this method or one of the more specific methods for creating specific kinds of Transformations.

Geom::Transformation.new with no arguments creates a new identify Transformation.

Geom::Transformation.new(pt) creates a Transformation that translates the origin to pt.

Geom::Transformation.new(vec) creates a Transformation that translates by vector vec.

Geom::Transformation.new(transform) creates a Transformation that is a copy of another Transformation. This is equivalent to transform.clone.

Geom::Transformation.new(array) creates a Transformation from a 16 element Array.

Geom::Transformation.new(scale) creates a Transformation that does uniform scaling.

Geom::Transformation.new(origin, zaxis) creates a Transformation where origin is the new origin, and zaxis is the z axis. The x and y axes are determined using an arbitrary axis rule.

Geom::Transformation.new(pt, xaxis, yaxis) creates a Transformation given a new origin, x axis and y axis.

Geom::Transformation.new(pt, axis, angle) creates a Transformation that rotates by angle (given in radians) about a line defined by pt and axis.

Geom::Transformation.new(xaxis, yaxis, zaxis, origin) creates a Transformation from 3 axes and an origin.

Arguments:

param1
(optional) A Point3d, Vector3d, Transformation, Array, or Float, depending on the kind of transformation you wish to create (see comments)
param2
(optional) An axis (see comments)
param3
(optional) An axis or angle (see comments)

Returns:

tranformation
a new Transformation object
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 if (t)
   UI.messagebox
 else
   UI.messagebox "Failure"
 end

Transformation.originSketchUp 6.0+

The origin method retrieves the origin of a rigid transformation.

Returns:

point
a Point3d object representing the origin of the transformation.
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 point2 = t.origin
 UI.messagebox point2

Transformation.rotationSketchUp 6.0+

The rotation method is used to create a Transformation that does rotation about an axis.

The axis is defined by a point and a vector. The angle is given in radians.

Arguments:

point
A Point3d object.
vector
A Vector3d object.
angle
A numeric value, expressed in radians, that specifies the angle to rotate about the axis set by the second parameter.

Returns:

transformation
a new Transformation object
 transformation = Geom::Transformation.rotation point, vector, angle

Transformation.scalingSketchUp 6.0+

The scaling method is used to create a Transformation that does scaling.

  • t = Geom::Transformation.scaling scale
  • t = Geom::Transformation.scaling xscale, yscale, zscale
  • t = Geom::Transformation.scaling point, scale
  • t = Geom::Transformation.scaling point, xscale, yscale, zscale


  • With one argument, it does a uniform scale about the origin.
  • With two arguments, it does a uniform scale about an arbitrary point.
  • With three arguments, it does a non-uniform scale about the origin.
  • With four arguments it does a non-uniform scale about an arbitrary point.
  • Arguments:

    scale
    A single numeric value used to set a global scale factor for the transform.
    xscale
    (optional) A numeric value specifying the scale factor in the x direction for the transform.
    yscale
    (optional) A numeric value specifying the scale factor in the y direction for the transform.
    zscale
    (optional) A numeric value specifying the scale factor in the z direction for the transform.
    point
    A Point3d object.

    Returns:

    transformation
    a new Transformation object
     t = Geom::Transformation.scaling 10
     UI.messagebox t

Transformation.set!SketchUp 6.0+

The set! method is used to set this transformation to match another one.

The argument is anything that can be converted into a Transformation.

Arguments:

transform2
A Transformation object to match.

Returns:

transformation1
a Transformation object matching transform2
 transformation1 = transformation1.set! transformation2

Transformation.to_aSketchUp 6.0+

The to_a method retrieves a 16 element array which contains the values that define the Transformation.

Returns:

array
an Array element containing the values that define the transformation
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 a = t.to_a
 UI.messagebox a

Transformation.translationSketchUp 6.0+

The translation method is used to create a transformation that does translation.

Arguments:

vector
A Vector3d object.

Returns:

transformation
a new Transformation object
 vector = Geom::Vector3d.new 0,1,0
 t = Geom::Transformation.translation vector
 UI.messagebox t

Transformation.xaxisSketchUp 6.0+

The xaxis method retrieves the x axis of a rigid transformation.

Returns:

point
a Point3d object containing the xaxis value.
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 x = t.xaxis
 UI.messagebox x

Transformation.yaxisSketchUp 6.0+

The yaxis method retrieves the y axis of a rigid transformation.

Returns:

point
a Point3d object containing the yaxis value.
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 y = t.yaxis
 UI.messagebox y

Transformation.zaxisSketchUp 6.0+

The yaxis method retrieves the z axis of a rigid transformation.

Returns:

point
a Point3d object containing the yaxis value.
 point = Geom::Point3d.new 10,20,30
 t = Geom::Transformation.new point
 z = t.zaxis
 UI.messagebox z