Class: Geom::Transformation
- Inherits:
-
Object
- Object
- Geom::Transformation
Overview
A column-major 4 × 4 matrix for translation, rotation, scaling, and composition by matrix multiplication.
Class Method Summary # collapse
-
.new ⇒ Geom::Transformation
With no arguments, constructs the identity. A point or vector specifies translation, a single number specifies uniform scaling, and an existing transformation is copied. An array of 16 numbers supplies a column-major matrix. With an origin and zaxis, the arbitrary-axis rule supplies X and Y. With three arguments, a numeric third argument specifies rotation about an axis in radians. Otherwise the arguments specify an origin and X and Y axes. Four arguments specify the X, Y, and Z axes followed by the origin. Axes specify directions only. To include scale in a matrix, use the 16-element array.
-
.translation(point) ⇒ Geom::Transformation
Translation.
-
.rotation(origin, axis, angle) ⇒ Geom::Transformation
Rotates by angle radians around an axis passing through origin with direction axis.
-
.scaling(scale) ⇒ Geom::Transformation
Uniform or axis-aligned scaling; scale about a point when an origin is specified.
-
.axes(origin, xaxis, yaxis) ⇒ Geom::Transformation
Construct a coordinate system transformation from the origin and axis vectors. Omitting zaxis uses X×Y.
-
.interpolate(transformation1, transformation2, weight) ⇒ Geom::Transformation
Linearly interpolate matrix elements between two transformations based on weight (0..1).
Instance Method Summary # collapse
-
#to_a ⇒ Array<Numeric>
16 numbers, in column-major order.
-
#origin ⇒ Geom::Point3d
The translation component.
-
#xaxis ⇒ Geom::Vector3d
The X-axis of the rigid transformation (matrix first column, includes scaling).
-
#yaxis ⇒ Geom::Vector3d
The Y-axis of the rigid transformation (matrix second column, including scaling).
-
#zaxis ⇒ Geom::Vector3d
The Z-axis of the rigid transformation (matrix's third column, including scaling).
-
#rotx ⇒ Numeric
Euler angle rotation around the X-axis in degrees.
-
#roty ⇒ Numeric
Euler angle rotation around the Y-axis in degrees.
-
#rotz ⇒ Numeric
Euler angle rotation around the Z-axis, in degrees.
-
#identity? ⇒ Boolean
Returns whether the transformation is an identity matrix.
-
#inverse ⇒ Geom::Transformation
Inverse transformation. Throws an error if not invertible.
-
#invert! ⇒ Geom::Transformation
Inverts the transformation in place. Raises an error if inversion is not possible.
-
#clone ⇒ Geom::Transformation
Clones a transformation.
-
#set!(other) ⇒ Geom::Transformation
Overwrite itself with another transformation, point (translation), vector (translation), 16-element array, or uniform scale factor.
-
#* ⇒ Geom::Transformation, Geom::Point3d, Geom::Vector3d, Array<Numeric>
Multiply by another transformation, point, vector, [x, y, z], or plane (quadruple [a, b, c, d] / [point, normal]).
Class Method Details
Transformation.new ⇒ transformationTransformation.new(point) ⇒ transformationTransformation.new(vector) ⇒ transformationTransformation.new(transformation) ⇒ transformationTransformation.new(array16) ⇒ transformationTransformation.new(scale) ⇒ transformationTransformation.new(origin, zaxis) ⇒ transformationTransformation.new(origin, xaxis, yaxis) ⇒ transformationTransformation.new(origin, axis, angle) ⇒ transformationTransformation.new(xaxis, yaxis, zaxis, origin) ⇒ transformation
With no arguments, constructs the identity. A point or vector specifies translation, a single number specifies uniform scaling, and an existing transformation is copied. An array of 16 numbers supplies a column-major matrix. With an origin and zaxis, the arbitrary-axis rule supplies X and Y. With three arguments, a numeric third argument specifies rotation about an axis in radians. Otherwise the arguments specify an origin and X and Y axes. Four arguments specify the X, Y, and Z axes followed by the origin. Axes specify directions only. To include scale in a matrix, use the 16-element array.
Transformation.translation(point) ⇒ transformationTransformation.translation(vector) ⇒ transformationTransformation.translation(x, y, z) ⇒ transformation
Translation.
Transformation.rotation(origin, axis, angle) ⇒ transformation
Rotates by angle radians around an axis passing through origin with direction axis.
Transformation.scaling(scale) ⇒ transformationTransformation.scaling(xscale, yscale, zscale) ⇒ transformationTransformation.scaling(origin, scale) ⇒ transformationTransformation.scaling(origin, xscale, yscale, zscale) ⇒ transformation
Uniform or axis-aligned scaling; scale about a point when an origin is specified.
Transformation.axes(origin, xaxis, yaxis) ⇒ transformationTransformation.axes(origin, xaxis, yaxis, zaxis) ⇒ transformation
Construct a coordinate system transformation from the origin and axis vectors. Omitting zaxis uses X×Y. Axes are normalized to be orthogonal directions, with length not scaling (same as SketchUp Transformation.axes). For scaling, use a 16-element array to construct the matrix.
Transformation.interpolate(transformation1, transformation2, weight) ⇒ transformation
Linearly interpolate matrix elements between two transformations based on weight (0..1).
Instance Method Details
transformation.to_a ⇒ Array<Numeric>
16 numbers, in column-major order.
transformation.origin ⇒ Geom::Point3d
The translation component.
transformation.xaxis ⇒ Geom::Vector3d
The X-axis of the rigid transformation (matrix first column, includes scaling).
transformation.yaxis ⇒ Geom::Vector3d
The Y-axis of the rigid transformation (matrix second column, including scaling).
transformation.zaxis ⇒ Geom::Vector3d
The Z-axis of the rigid transformation (matrix's third column, including scaling).
transformation.rotx ⇒ Numeric
Euler angle rotation around the X-axis in degrees.
Dynamic Components loaded afterward will override this method.
transformation.roty ⇒ Numeric
Euler angle rotation around the Y-axis in degrees.
Dynamic Components loaded afterward will override this method.
transformation.rotz ⇒ Numeric
Euler angle rotation around the Z-axis, in degrees.
Dynamic Components loaded afterward will override this method.
transformation.identity? ⇒ Boolean
Returns whether the transformation is an identity matrix.
transformation.inverse ⇒ Geom::Transformation
Inverse transformation. Throws an error if not invertible.
transformation.invert! ⇒ self
Inverts the transformation in place. Raises an error if inversion is not possible.
transformation.clone ⇒ Geom::Transformation
Clones a transformation.
transformation.set!(other) ⇒ self
Overwrite itself with another transformation, point (translation), vector (translation), 16-element array, or uniform scale factor.
transformation * other ⇒ Geom::Transformation, Geom::Point3d, Geom::Vector3d, Array<Numeric>
Multiply by another transformation, point, vector, [x, y, z], or plane (quadruple [a, b, c, d] / [point, normal]).