Class: Geom::Transformation

Inherits:
Object
show all
Defined in:
lib/transformation.rb

Class Method Summary collapse

• Creates a transformation from 3 axis and an origin.

• Create a new transformation that is the result of interpolating between two other transformations.

• Creates a new transformation that does a counter-clockwise rotation about an axis by given angle.

• Creates a new transformation that does a scaling.

• Creates a new transformation that translates by the given vector.

Instance Method Summary collapse

• Matrix multiplication.

• Creates another transformation identical to the transformation being cloned.

• Determines if this transformation is an identity transformation, that means that applying it to a geometry won't modify it.

• constructor

Creates a new transformation object.

• Creates a new transformation that is the inverse of this transformation.

• Modifies this transformation to its inverse.

• Retrieves the origin of a transformation.

• Sets this transformation to match another one.

• Returns an array representation of this transformation.

• Retrieves the x-axis of this transformation.

• Retrieves the y-axis of this transformation.

• Retrieves the z-axis of this transformation.

Constructor Details

#initialize ⇒ Transformation #initialize(point) ⇒ Transformation #initialize(vector) ⇒ Transformation #initialize(transformation) ⇒ Transformation #initialize(array) ⇒ Transformation #initialize(scale) ⇒ Transformation #initialize(origin, zaxis) ⇒ Transformation #initialize(origin, xaxis, yaxis) ⇒ Transformation #initialize(point, axis, angle) ⇒ Transformation #initialize(xaxis, yaxis, zaxis, origin) ⇒ Transformation

Creates a new transformation object.

• #initializeTransformation

Creates a new identity transformation.

• #initialize(point) ⇒ Transformation

Creates a transformation that translates by the vector from the origin to the given point.

Parameters:

• point
• #initialize(vector) ⇒ Transformation

Creates a transformation that translates by the given vector.

Parameters:

• vector
• #initialize(transformation) ⇒ Transformation

Creates a transformation that is a copy of the given transformation. This is equivalent to #clone.

Parameters:

• transformation
• #initialize(array) ⇒ Transformation

Creates a transformation from a 16 element array that represents a transformation matrix in row major ordering.

Parameters:

• #initialize(scale) ⇒ Transformation

Creates a transformation that does uniform scaling.

Parameters:

• #initialize(origin, zaxis) ⇒ Transformation

Creates an axis transformation where where xaxis and yaxis are arbitrarily chosen.

Parameters:

• origin
• zaxis
• #initialize(origin, xaxis, yaxis) ⇒ Transformation

Creates an axis transformation from origin, xaxis and yaxis. The zaxis is set orthogonal to the given axis according to the right-hand rule.

Parameters:

• origin
• xaxis
• yaxis
• #initialize(point, axis, angle) ⇒ Transformation

Creates a transformation that rotates counter-clockwise about an axis by given angle.

Parameters:

• point
• axis
• angle (Numeric)

The angle in radians

• #initialize(xaxis, yaxis, zaxis, origin) ⇒ Transformation

Creates a transformation from 3 axis and an origin.

Parameters:

• xaxis
• yaxis
• zaxis
• origin
 45 46 # File 'lib/transformation.rb', line 45 def initialize(*args) end

Class Method Details

.axes(origin, xaxis, yaxis, zaxis) ⇒ Geom::Transformation

Creates a transformation from 3 axis and an origin.

Parameters:

• origin
• xaxis
• yaxis
• zaxis

Returns:

 65 66 # File 'lib/transformation.rb', line 65 def self.axes(origin, xaxis, yaxis, zaxis) end

.interpolate ⇒ Geom::Point3d

Note:

This method fails to interpolate if a uniform scaling is not realized by the three diagonal matrix elements but by the last matrix element. In that case, it would return the first transformation for parameter 0 and

Note:

Note transformation matrices are not suited for interpolating rotations: An rotation by 180 would "squeeze" the transformed object through the rotation axis and then expand to the final state instead of rotating either left way or right way.

Create a new transformation that is the result of interpolating between two other transformations. Creates a new point as a linear combination of two points. This method is generally used to get a point at some percentage along a line connecting the two points. The weights should sum up to 1 if you want to get a on that line. The weights should be between 0 and 1 if you want to get a point between the two points. otherwise the second transformation.

Parameters:

• weight1 (Numeric)

The weight of point1.

• point1
• parameter (Numeric)

The weight of point2.

• point2

Returns:

 96 97 # File 'lib/transformation.rb', line 96 def self.interpolate end

.rotation(point, vector, angle) ⇒ Geom::Transformation

Creates a new transformation that does a counter-clockwise rotation about an axis by given angle.

Parameters:

• point

A point on the axis of rotation

• vector

A vector defining the direction of the axis

• angle (Numeric)

The angle in radians

Returns:

• The new rotation transformation

 119 120 # File 'lib/transformation.rb', line 119 def self.rotation(point, vector, angle) end

.self.scaling(scale) ⇒ Geom::Transformation .self.scaling(point, scale) ⇒ Geom::Transformation .self.scaling(xscale, yscale, zscale) ⇒ Geom::Transformation .self.scaling(xscale, yscale, zscale) ⇒ Geom::Transformation

Creates a new transformation that does a scaling.

• .self.scaling(scale) ⇒ Geom::Transformation

Uniform scaling about the origin.

Parameters:

• scale (Numeric)

Uniform scaling factor for all three axes

• .self.scaling(point, scale) ⇒ Geom::Transformation

Uniform scaling about a given point.

Parameters:

• point
• scale (Numeric)

Uniform scaling factor for all three axes

• .self.scaling(xscale, yscale, zscale) ⇒ Geom::Transformation

Non-uniform scaling about the origin.

Parameters:

• xscale (Numeric)

Scaling factor along the x-axis

• yscale (Numeric)

Scaling factor along the y-axis

• zscale (Numeric)

Scaling factor along the z-axis

• .self.scaling(xscale, yscale, zscale) ⇒ Geom::Transformation

Non-uniform scaling about a given point.

Parameters:

• point
• xscale (Numeric)

Scaling factor along the x-axis

• yscale (Numeric)

Scaling factor along the y-axis

• zscale (Numeric)

Scaling factor along the z-axis

Returns:

• The new scaling transformation

 142 143 # File 'lib/transformation.rb', line 142 def self.scaling end

.translation(vector) ⇒ Geom::Transformation

Creates a new transformation that translates by the given vector.

Parameters:

• vector

Returns:

• The new rotation transformation

 162 163 # File 'lib/transformation.rb', line 162 def self.translation(vector) end

Instance Method Details

#*(point) ⇒ Geom::Transformation #*(vector) ⇒ Geom::Transformation #*(transformation) ⇒ Geom::Transformation

Matrix multiplication

Returns:

 56 57 # File 'lib/transformation.rb', line 56 def *(arg) end

#clone ⇒ Geom::Transformation

Creates another transformation identical to the transformation being cloned.

Returns:

• A new transformation that is a copy of this one.

 70 71 # File 'lib/transformation.rb', line 70 def clone end

#identity? ⇒ Boolean

Note:

There is an issue that this method returns only true for transformations initialized as identity, either with Transformation.new or from the constant Geom::Transformation::Identity

Determines if this transformation is an identity transformation, that means that applying it to a geometry won't modify it.

Returns:

• (Boolean)

true if this transformation is an identity transformation

 78 79 # File 'lib/transformation.rb', line 78 def identity? end

#inverse ⇒ Geom::Transformation

Creates a new transformation that is the inverse of this transformation.

Returns:

 101 102 # File 'lib/transformation.rb', line 101 def inverse end

#invert! ⇒ self

Modifies this transformation to its inverse.

Returns:

• (self)
 106 107 # File 'lib/transformation.rb', line 106 def invert! end

#origin ⇒ Geom::Point3d

Retrieves the origin of a transformation.

Returns:

 111 112 # File 'lib/transformation.rb', line 111 def origin end

#set!(transformation) ⇒ self #set!(array) ⇒ self

Sets this transformation to match another one.

• #set!(transformation) ⇒ self

Parameters:

• transformation

Another transformation object

• #set!(array) ⇒ self

Parameters:

• array (Array<Numeric>)

A 16 element array of a transformation matrix in row major ordering.

Returns:

• (self)
 151 152 # File 'lib/transformation.rb', line 151 def set!(transformation) end

#to_a ⇒ Array<Float>

Returns an array representation of this transformation.

Returns:

• (Array<Float>)

A 16 element array the matrix elements.

 156 157 # File 'lib/transformation.rb', line 156 def to_a end

#xaxis ⇒ Geom::Vector3d

Retrieves the x-axis of this transformation.

Returns:

 167 168 # File 'lib/transformation.rb', line 167 def xaxis end

#yaxis ⇒ Geom::Vector3d

Retrieves the y-axis of this transformation.

Returns:

 172 173 # File 'lib/transformation.rb', line 172 def yaxis end

#zaxis ⇒ Geom::Vector3d

Retrieves the z-axis of this transformation.

Returns:

 177 178 # File 'lib/transformation.rb', line 177 def zaxis end