Class: Numerix::Matrix3x2
- Inherits:
-
MatrixBase
- Object
- Structure
- MatrixBase
- Numerix::Matrix3x2
- Defined in:
- lib/numerix/matrix3x2.rb
Overview
A structure encapsulating a 3x2 matrix.
Instance Attribute Summary collapse
-
#m11 ⇒ Float
The first element of the first row.
-
#m12 ⇒ Float
The second element of the first row.
-
#m21 ⇒ Float
The first element of the second row.
-
#m22 ⇒ Float
The second element of the second row.
-
#m31 ⇒ Float
The first element of the third row.
-
#m32 ⇒ Float
The second element of the third row.
-
#translation ⇒ Vector2
The translation component of this matrix.
Class Method Summary collapse
-
.create_rotation ⇒ Matrix3x2
Creates a rotation matrix.
-
.create_scale(*args) ⇒ Matrix3x2
Creates a scale matrix.
-
.create_skew(*args) ⇒ Matrix3x2
Creates a skew matrix.
-
.create_translation(other) ⇒ Matrix3x2
Creates a translation matrix.
-
.identity ⇒ Matrix3x2
The multiplicative identity matrix.
-
.lerp(matrix1, matrix2, amount) ⇒ Matrix3x2
Linearly interpolates from matrix1 to matrix2, based on the third parameter.
Instance Method Summary collapse
-
#*(other) ⇒ Matrix3x2
Multiplies this matrix by the specified value.
-
#**(exponent) ⇒ Matrix3x2
Raises the matrix to the given power.
-
#+(other) ⇒ Matrix3x2
Adds each matrix element in value1 with its corresponding element in the specified matrix.
-
#-(other) ⇒ Matrix3x2
Subtracts each matrix element in the specified matrix from its corresponding element in this matrix to form a new matrix of the difference.
-
#-@ ⇒ Matrix3x2
Negates the given matrix by multiplying all values by
-1.0. -
#==(other) ⇒ Boolean
Returns flag if this matrix instance is equal to the given object.
-
#[](row, column) ⇒ Float?
Accesses the matrix component using the zero-based row/column indices.
-
#[]=(row, column, value) ⇒ Float
Sets the matrix component using the zero-based row/column indices.
-
#column(index) ⇒ Array<Float>?
Returns the specified matrix column as an array.
-
#determinant ⇒ Float
Calculates the determinant for this matrix.
-
#each_column {|column| ... } ⇒ self
Enumerates the columns of the matrix.
-
#each_row {|row| ... } ⇒ self
Enumerates the rows of the matrix.
-
#identity? ⇒ Boolean
trueif the matrix is the identity matrix, otherwisefalse. -
#initialize(*args) ⇒ Matrix3x2
constructor
A new instance of Matrix3x2.
-
#invert ⇒ Matrix3x2
Attempts to invert the given matrix.
-
#lerp(matrix, amount) ⇒ Matrix3x2
Linearly interpolates from this matrix to another, based on the amount.
-
#lerp!(matrix, amount) ⇒ self
Linearly interpolates from this matrix to another, based on the amount.
-
#map {|component| ... } ⇒ Matrix3x2
(also: #collect)
The equivalent of
Enumerable#map, but returns a matrix object instead of an Array. -
#map! {|component| ... } ⇒ self
(also: #collect!)
Invokes the given block once for each element of self, replacing the element with the value returned by the block.
-
#row(index) ⇒ Array<Float>?
Returns the specified matrix row as an array.
-
#to_a ⇒ Array<Array<Float>>
(also: #elements)
An Array representation of this instance.
-
#to_h ⇒ Hash{Symbol => Float}
A Hash representation of this instance.
-
#to_s ⇒ String
A String representation of this instance.
Methods inherited from Structure
#address, #dup, #each, #pack, #ptr, size, unpack
Constructor Details
Instance Attribute Details
#m11 ⇒ Float
Returns the first element of the first row.
9 10 11 |
# File 'lib/numerix/matrix3x2.rb', line 9 def m11 @m11 end |
#m12 ⇒ Float
Returns the second element of the first row.
13 14 15 |
# File 'lib/numerix/matrix3x2.rb', line 13 def m12 @m12 end |
#m21 ⇒ Float
Returns the first element of the second row.
17 18 19 |
# File 'lib/numerix/matrix3x2.rb', line 17 def m21 @m21 end |
#m22 ⇒ Float
Returns the second element of the second row.
21 22 23 |
# File 'lib/numerix/matrix3x2.rb', line 21 def m22 @m22 end |
#m31 ⇒ Float
Returns the first element of the third row.
25 26 27 |
# File 'lib/numerix/matrix3x2.rb', line 25 def m31 @m31 end |
#m32 ⇒ Float
Returns the second element of the third row.
29 30 31 |
# File 'lib/numerix/matrix3x2.rb', line 29 def m32 @m32 end |
#translation ⇒ Vector2
Returns the translation component of this matrix.
33 34 35 |
# File 'lib/numerix/matrix3x2.rb', line 33 def translation @translation end |
Class Method Details
.create_rotation(radians) ⇒ Matrix3x2 .create_rotation(radians, center) ⇒ Matrix3x2
Creates a rotation matrix.
403 404 |
# File 'lib/numerix/matrix3x2.rb', line 403 def create_rotation end |
.create_scale(x, y) ⇒ Matrix3x2 .create_scale(x, y, center) ⇒ Matrix3x2 .create_scale(scales) ⇒ Matrix3x2 .create_scale(scales, center) ⇒ Matrix3x2 .create_scale(scale) ⇒ Matrix3x2 .create_scale(scale, center) ⇒ Matrix3x2
Creates a scale matrix.
363 364 |
# File 'lib/numerix/matrix3x2.rb', line 363 def create_scale(*args) end |
.create_skew(x, y) ⇒ Matrix3x2 .create_skew(x, y, center) ⇒ Matrix3x2
Creates a skew matrix.
384 385 |
# File 'lib/numerix/matrix3x2.rb', line 384 def create_skew(*args) end |
.create_translation(position) ⇒ Matrix3x2 .create_translation(x, y) ⇒ Matrix3x2
Creates a translation matrix.
319 320 |
# File 'lib/numerix/matrix3x2.rb', line 319 def create_translation(other) end |
.identity ⇒ Matrix3x2
Returns the multiplicative identity matrix.
301 302 |
# File 'lib/numerix/matrix3x2.rb', line 301 def identity end |
.lerp(matrix1, matrix2, amount) ⇒ Matrix3x2
Linearly interpolates from matrix1 to matrix2, based on the third parameter.
416 417 |
# File 'lib/numerix/matrix3x2.rb', line 416 def lerp(matrix1, matrix2, amount) end |
Instance Method Details
#*(scalar) ⇒ Matrix3x2 #*(other) ⇒ Matrix3x2
Multiplies this matrix by the specified value.
263 264 |
# File 'lib/numerix/matrix3x2.rb', line 263 def *(other) end |
#**(exponent) ⇒ Matrix3x2
Raises the matrix to the given power.
98 99 |
# File 'lib/numerix/matrix3x2.rb', line 98 def **(exponent) end |
#+(other) ⇒ Matrix3x2
Adds each matrix element in value1 with its corresponding element in the specified matrix.
235 236 |
# File 'lib/numerix/matrix3x2.rb', line 235 def +(other) end |
#-(other) ⇒ Matrix3x2
Subtracts each matrix element in the specified matrix from its corresponding element in this matrix to form a new matrix of the difference.
246 247 |
# File 'lib/numerix/matrix3x2.rb', line 246 def -(other) end |
#-@ ⇒ Matrix3x2
Negates the given matrix by multiplying all values by -1.0.
225 226 |
# File 'lib/numerix/matrix3x2.rb', line 225 def -@ end |
#==(other) ⇒ Boolean
Returns flag if this matrix instance is equal to the given object.
272 273 |
# File 'lib/numerix/matrix3x2.rb', line 272 def ==(other) end |
#[](row, column) ⇒ Float?
Accesses the matrix component using the zero-based row/column indices.
283 284 |
# File 'lib/numerix/matrix3x2.rb', line 283 def [](row, column) end |
#[]=(row, column, value) ⇒ Float
Sets the matrix component using the zero-based row/column indices.
294 295 |
# File 'lib/numerix/matrix3x2.rb', line 294 def []=(row, column, value) end |
#column(index) ⇒ Array<Float>?
Returns the specified matrix column as an array.
138 139 |
# File 'lib/numerix/matrix3x2.rb', line 138 def column(index) end |
#determinant ⇒ Float
Calculates the determinant for this matrix.
The determinant is calculated by expanding the matrix with a third column whose values are (0,0,1).
114 115 |
# File 'lib/numerix/matrix3x2.rb', line 114 def determinant end |
#each_column {|column| ... } ⇒ self
Enumerates the columns of the matrix.
162 163 |
# File 'lib/numerix/matrix3x2.rb', line 162 def each_column end |
#each_row {|row| ... } ⇒ self
Enumerates the rows of the matrix.
see each_column
150 151 |
# File 'lib/numerix/matrix3x2.rb', line 150 def each_row end |
#identity? ⇒ Boolean
Returns true if the matrix is the identity matrix, otherwise
false.
104 105 |
# File 'lib/numerix/matrix3x2.rb', line 104 def identity? end |
#invert ⇒ Matrix3x2
Some matrices cannot be inverted, in which case the returned matrix
will have all values set to NaN.
Attempts to invert the given matrix.
172 173 |
# File 'lib/numerix/matrix3x2.rb', line 172 def invert end |
#lerp(matrix, amount) ⇒ Matrix3x2
Linearly interpolates from this matrix to another, based on the amount.
185 186 |
# File 'lib/numerix/matrix3x2.rb', line 185 def lerp(matrix, amount) end |
#lerp!(matrix, amount) ⇒ self
This method is the same as #lerp, but alters the values of this matrix instead of creating a new instance.
Linearly interpolates from this matrix to another, based on the amount.
201 202 |
# File 'lib/numerix/matrix3x2.rb', line 201 def lerp!(matrix, amount) end |
#map {|component| ... } ⇒ Matrix3x2 Also known as: collect
The equivalent of Enumerable#map, but returns a matrix object instead of
an Array.
Invokes the given block once for each element of self.
Creates a new matrix containing the values returned by the block.
71 72 |
# File 'lib/numerix/matrix3x2.rb', line 71 def map end |
#map! {|component| ... } ⇒ self Also known as: collect!
Invokes the given block once for each element of self, replacing the element with the value returned by the block.
The values of the matrix are altered without creating a ne object.
86 87 |
# File 'lib/numerix/matrix3x2.rb', line 86 def map! end |
#row(index) ⇒ Array<Float>?
Returns the specified matrix row as an array.
126 127 |
# File 'lib/numerix/matrix3x2.rb', line 126 def row(index) end |
#to_a ⇒ Array<Array<Float>> Also known as: elements
Returns an Array representation of this instance.
211 212 |
# File 'lib/numerix/matrix3x2.rb', line 211 def to_a end |
#to_h ⇒ Hash{Symbol => Float}
Returns a Hash representation of this instance.
218 219 |
# File 'lib/numerix/matrix3x2.rb', line 218 def to_h end |
#to_s ⇒ String
Returns a String representation of this instance.
206 207 |
# File 'lib/numerix/matrix3x2.rb', line 206 def to_s end |