Class: Numerix::Matrix4x4
- Inherits:
-
MatrixBase
- Object
- Structure
- MatrixBase
- Numerix::Matrix4x4
- Defined in:
- lib/numerix/matrix4x4.rb
Overview
A structure encapsulating a 4x4 matrix.
Instance Attribute Summary collapse
-
#m11 ⇒ Float
Value at row 1, column 1 of the matrix.
-
#m12 ⇒ Float
Value at row 1, column 2 of the matrix.
-
#m13 ⇒ Float
Value at row 1, column 3 of the matrix.
-
#m14 ⇒ Float
Value at row 1, column 4 of the matrix.
-
#m21 ⇒ Float
Value at row 2, column 1 of the matrix.
-
#m22 ⇒ Float
Value at row 2, column 2 of the matrix.
-
#m23 ⇒ Float
Value at row 2, column 3 of the matrix.
-
#m24 ⇒ Float
Value at row 2, column 4 of the matrix.
-
#m31 ⇒ Float
Value at row 3, column 1 of the matrix.
-
#m32 ⇒ Float
Value at row 3, column 2 of the matrix.
-
#m33 ⇒ Float
Value at row 3, column 3 of the matrix.
-
#m34 ⇒ Float
Value at row 3, column 4 of the matrix.
-
#m41 ⇒ Float
Value at row 4, column 1 of the matrix.
-
#m42 ⇒ Float
Value at row 4, column 2 of the matrix.
-
#m43 ⇒ Float
Value at row 4, column 3 of the matrix.
-
#m44 ⇒ Float
Value at row 4, column 4 of the matrix.
-
#translation ⇒ Vector3
The translation component of this matrix.
Class Method Summary collapse
-
.create_billboard(position, camera, up, forward) ⇒ Matrix4x4
Creates a spherical billboard that rotates around a specified object position.
-
.create_constrained_billboard(position, camera, axis, cam_forward, obj_forward) ⇒ Matrix4x4
Creates a cylindrical billboard that rotates around a specified axis.
-
.create_look_at(camera, target, up) ⇒ Matrix4x4
Creates a view matrix.
-
.create_orthographic(width, height, near, far) ⇒ Matrix4x4
Creates an orthographic perspective matrix from the given view volume dimensions.
-
.create_orthographic_off_center(left, right, bottom, top, near, far) ⇒ Matrix4x4
Builds a customized, orthographic projection matrix.
-
.create_perspective(width, height, near, far) ⇒ Vector3
Creates a perspective projection matrix from the given view volume dimensions.
-
.create_perspective_fov(fov, ratio, near, far) ⇒ Vector3
Creates a perspective projection matrix based on a field of view, aspect ratio, and near and far view plane distances.
-
.create_perspective_off_center(left, right, bottom, top, near, far) ⇒ Vector3
Creates a customized, perspective projection matrix.
-
.create_reflection(plane) ⇒ Matrix4x4
Creates a Matrix that reflects the coordinate system about a specified plane.
-
.create_rotation_x ⇒ Matrix4x4
Creates a matrix for rotating points around the X-axis.
-
.create_rotation_y ⇒ Matrix4x4
Creates a matrix for rotating points around the Y-axis.
-
.create_rotation_z ⇒ Matrix4x4
Creates a matrix for rotating points around the Z-axis.
-
.create_scale ⇒ Matrix4x4
Creates a scaling matrix.
-
.create_shadow(direction, plane) ⇒ Matrix4x4
Creates a Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source.
-
.create_translation ⇒ Matrix4x4
Creates a translation matrix.
-
.create_world(position, forward, up) ⇒ Matrix4x4
Creates a world matrix with the specified parameters.
-
.from_axis_angle(axis, angle) ⇒ Matrix4x4
Creates a matrix that rotates around an arbitrary vector.
-
.from_quaternion(quaternion) ⇒ Matrix4x4
Creates a rotation matrix from the given quaternion rotation value.
-
.from_yaw_pitch_roll(yaw, pitch, roll) ⇒ Matrix4x4
Creates a rotation matrix from the specified yaw, pitch, and roll.
-
.identity ⇒ Matrix4x4
The multiplicative identity matrix.
-
.lerp(matrix1, matrix2, amount) ⇒ Matrix4x4
Linearly interpolates from matrix1 to matrix2, based on the third parameter.
Instance Method Summary collapse
-
#*(other) ⇒ Matrix4x4
Multiplies this matrix by the specified value.
-
#**(exponent) ⇒ Matrix4x4
Raises the matrix to the given power.
-
#+(other) ⇒ Matrix4x4
Adds each matrix element in value1 with its corresponding element in the specified matrix.
-
#-(other) ⇒ Matrix4x4
Subtracts each matrix element in the specified matrix from its corresponding element in this matrix to form a new matrix of the difference.
-
#-@ ⇒ Matrix4x4
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) ⇒ Matrix4x4
constructor
A new instance of Matrix4x4.
-
#invert ⇒ Matrix4x4
Attempts to invert the given matrix.
-
#lerp(matrix, amount) ⇒ Matrix4x4
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| ... } ⇒ Matrix4x4
(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.
-
#transform(rotation) ⇒ Matrix4x4
Creates a matrix by transforming this instance by applying the given quaternion rotation.
-
#transform!(rotation) ⇒ self
Transforms this matrix by applying the given quaternion rotation.
-
#transpose ⇒ Matrix4x4
Transposes the rows and columns of a matrix.
Methods inherited from Structure
#address, #dup, #each, #pack, #ptr, size, unpack
Constructor Details
#initialize ⇒ Matrix4x4 #initialize(matrix) ⇒ Matrix4x4 #initialize(value) ⇒ Matrix4x4 #initialize(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) ⇒ Matrix4x4
Returns a new instance of Matrix4x4.
109 110 |
# File 'lib/numerix/matrix4x4.rb', line 109 def initialize(*args) end |
Instance Attribute Details
#m11 ⇒ Float
Returns Value at row 1, column 1 of the matrix.
9 10 11 |
# File 'lib/numerix/matrix4x4.rb', line 9 def m11 @m11 end |
#m12 ⇒ Float
Returns Value at row 1, column 2 of the matrix.
13 14 15 |
# File 'lib/numerix/matrix4x4.rb', line 13 def m12 @m12 end |
#m13 ⇒ Float
Returns Value at row 1, column 3 of the matrix.
17 18 19 |
# File 'lib/numerix/matrix4x4.rb', line 17 def m13 @m13 end |
#m14 ⇒ Float
Returns Value at row 1, column 4 of the matrix.
21 22 23 |
# File 'lib/numerix/matrix4x4.rb', line 21 def m14 @m14 end |
#m21 ⇒ Float
Returns Value at row 2, column 1 of the matrix.
25 26 27 |
# File 'lib/numerix/matrix4x4.rb', line 25 def m21 @m21 end |
#m22 ⇒ Float
Returns Value at row 2, column 2 of the matrix.
29 30 31 |
# File 'lib/numerix/matrix4x4.rb', line 29 def m22 @m22 end |
#m23 ⇒ Float
Returns Value at row 2, column 3 of the matrix.
33 34 35 |
# File 'lib/numerix/matrix4x4.rb', line 33 def m23 @m23 end |
#m24 ⇒ Float
Returns Value at row 2, column 4 of the matrix.
37 38 39 |
# File 'lib/numerix/matrix4x4.rb', line 37 def m24 @m24 end |
#m31 ⇒ Float
Returns Value at row 3, column 1 of the matrix.
41 42 43 |
# File 'lib/numerix/matrix4x4.rb', line 41 def m31 @m31 end |
#m32 ⇒ Float
Returns Value at row 3, column 2 of the matrix.
45 46 47 |
# File 'lib/numerix/matrix4x4.rb', line 45 def m32 @m32 end |
#m33 ⇒ Float
Returns Value at row 3, column 3 of the matrix.
49 50 51 |
# File 'lib/numerix/matrix4x4.rb', line 49 def m33 @m33 end |
#m34 ⇒ Float
Returns Value at row 3, column 4 of the matrix.
53 54 55 |
# File 'lib/numerix/matrix4x4.rb', line 53 def m34 @m34 end |
#m41 ⇒ Float
Returns Value at row 4, column 1 of the matrix.
57 58 59 |
# File 'lib/numerix/matrix4x4.rb', line 57 def m41 @m41 end |
#m42 ⇒ Float
Returns Value at row 4, column 2 of the matrix.
61 62 63 |
# File 'lib/numerix/matrix4x4.rb', line 61 def m42 @m42 end |
#m43 ⇒ Float
Returns Value at row 4, column 3 of the matrix.
65 66 67 |
# File 'lib/numerix/matrix4x4.rb', line 65 def m43 @m43 end |
#m44 ⇒ Float
Returns Value at row 4, column 4 of the matrix.
69 70 71 |
# File 'lib/numerix/matrix4x4.rb', line 69 def m44 @m44 end |
#translation ⇒ Vector3
Returns the translation component of this matrix.
73 74 75 |
# File 'lib/numerix/matrix4x4.rb', line 73 def translation @translation end |
Class Method Details
.create_billboard(position, camera, up, forward) ⇒ Matrix4x4
Creates a spherical billboard that rotates around a specified object position.
396 397 |
# File 'lib/numerix/matrix4x4.rb', line 396 def create_billboard(position, camera, up, forward) end |
.create_constrained_billboard(position, camera, axis, cam_forward, obj_forward) ⇒ Matrix4x4
Creates a cylindrical billboard that rotates around a specified axis.
410 411 |
# File 'lib/numerix/matrix4x4.rb', line 410 def create_constrained_billboard(position, camera, axis, cam_forward, obj_forward) end |
.create_look_at(camera, target, up) ⇒ Matrix4x4
Creates a view matrix.
591 592 |
# File 'lib/numerix/matrix4x4.rb', line 591 def create_look_at(camera, target, up) end |
.create_orthographic(width, height, near, far) ⇒ Matrix4x4
Creates an orthographic perspective matrix from the given view volume dimensions.
565 566 |
# File 'lib/numerix/matrix4x4.rb', line 565 def create_orthographic(width, height, near, far) end |
.create_orthographic_off_center(left, right, bottom, top, near, far) ⇒ Matrix4x4
Builds a customized, orthographic projection matrix.
579 580 |
# File 'lib/numerix/matrix4x4.rb', line 579 def create_orthographic_off_center(left, right, bottom, top, near, far) end |
.create_perspective(width, height, near, far) ⇒ Vector3
Creates a perspective projection matrix from the given view volume dimensions.
534 535 |
# File 'lib/numerix/matrix4x4.rb', line 534 def create_perspective(width, height, near, far) end |
.create_perspective_fov(fov, ratio, near, far) ⇒ Vector3
Creates a perspective projection matrix based on a field of view, aspect ratio, and near and far view plane distances.
521 522 |
# File 'lib/numerix/matrix4x4.rb', line 521 def create_perspective_fov(fov, ratio, near, far) end |
.create_perspective_off_center(left, right, bottom, top, near, far) ⇒ Vector3
Creates a customized, perspective projection matrix.
552 553 |
# File 'lib/numerix/matrix4x4.rb', line 552 def create_perspective_off_center(left, right, bottom, top, near, far) end |
.create_reflection(plane) ⇒ Matrix4x4
Creates a Matrix that reflects the coordinate system about a specified plane.
628 629 |
# File 'lib/numerix/matrix4x4.rb', line 628 def create_reflection(plane) end |
.create_rotation_x(radians) ⇒ Matrix4x4 .create_rotation_x(radians, center) ⇒ Matrix4x4
Creates a matrix for rotating points around the X-axis.
475 476 |
# File 'lib/numerix/matrix4x4.rb', line 475 def create_rotation_x end |
.create_rotation_y(radians) ⇒ Matrix4x4 .create_rotation_y(radians, center) ⇒ Matrix4x4
Creates a matrix for rotating points around the Y-axis.
491 492 |
# File 'lib/numerix/matrix4x4.rb', line 491 def create_rotation_y end |
.create_rotation_z(radians) ⇒ Matrix4x4 .create_rotation_z(radians, center) ⇒ Matrix4x4
Creates a matrix for rotating points around the Z-axis.
507 508 |
# File 'lib/numerix/matrix4x4.rb', line 507 def create_rotation_z end |
.create_scale(x, y, z) ⇒ Matrix4x4 .create_scale(x, y, z, center) ⇒ Matrix4x4 .create_scale(scales) ⇒ Matrix4x4 .create_scale(scales, center) ⇒ Matrix4x4 .create_scale(scale) ⇒ Matrix4x4 .create_scale(scale, center) ⇒ Matrix4x4
Creates a scaling matrix.
459 460 |
# File 'lib/numerix/matrix4x4.rb', line 459 def create_scale end |
.create_shadow(direction, plane) ⇒ Matrix4x4
Creates a Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source.
618 619 |
# File 'lib/numerix/matrix4x4.rb', line 618 def create_shadow(direction, plane) end |
.create_translation(position) ⇒ Matrix4x4 .create_translation(x, y, z) ⇒ Matrix4x4
Creates a translation matrix.
425 426 |
# File 'lib/numerix/matrix4x4.rb', line 425 def create_translation end |
.create_world(position, forward, up) ⇒ Matrix4x4
Creates a world matrix with the specified parameters.
604 605 |
# File 'lib/numerix/matrix4x4.rb', line 604 def create_world(position, forward, up) end |
.from_axis_angle(axis, angle) ⇒ Matrix4x4
Creates a matrix that rotates around an arbitrary vector.
639 640 |
# File 'lib/numerix/matrix4x4.rb', line 639 def from_axis_angle(axis, angle) end |
.from_quaternion(quaternion) ⇒ Matrix4x4
Creates a rotation matrix from the given quaternion rotation value.
648 649 |
# File 'lib/numerix/matrix4x4.rb', line 648 def from_quaternion(quaternion) end |
.from_yaw_pitch_roll(yaw, pitch, roll) ⇒ Matrix4x4
Creates a rotation matrix from the specified yaw, pitch, and roll.
659 660 |
# File 'lib/numerix/matrix4x4.rb', line 659 def from_yaw_pitch_roll(yaw, pitch, roll) end |
.identity ⇒ Matrix4x4
Returns the multiplicative identity matrix.
382 383 |
# File 'lib/numerix/matrix4x4.rb', line 382 def identity end |
.lerp(matrix1, matrix2, amount) ⇒ Matrix4x4
Linearly interpolates from matrix1 to matrix2, based on the third parameter.
672 673 |
# File 'lib/numerix/matrix4x4.rb', line 672 def lerp(matrix1, matrix2, amount) end |
Instance Method Details
#*(scalar) ⇒ Matrix4x4 #*(other) ⇒ Matrix4x4
Multiplies this matrix by the specified value.
308 309 |
# File 'lib/numerix/matrix4x4.rb', line 308 def *(other) end |
#**(exponent) ⇒ Matrix4x4
Raises the matrix to the given power.
153 154 |
# File 'lib/numerix/matrix4x4.rb', line 153 def **(exponent) end |
#+(other) ⇒ Matrix4x4
Adds each matrix element in value1 with its corresponding element in the specified matrix.
280 281 |
# File 'lib/numerix/matrix4x4.rb', line 280 def +(other) end |
#-(other) ⇒ Matrix4x4
Subtracts each matrix element in the specified matrix from its corresponding element in this matrix to form a new matrix of the difference.
291 292 |
# File 'lib/numerix/matrix4x4.rb', line 291 def -(other) end |
#-@ ⇒ Matrix4x4
Negates the given matrix by multiplying all values by -1.0.
270 271 |
# File 'lib/numerix/matrix4x4.rb', line 270 def -@ end |
#==(other) ⇒ Boolean
Returns flag if this matrix instance is equal to the given object.
317 318 |
# File 'lib/numerix/matrix4x4.rb', line 317 def ==(other) end |
#[](row, column) ⇒ Float?
Accesses the matrix component using the zero-based row/column indices.
328 329 |
# File 'lib/numerix/matrix4x4.rb', line 328 def [](row, column) end |
#[]=(row, column, value) ⇒ Float
Sets the matrix component using the zero-based row/column indices.
339 340 |
# File 'lib/numerix/matrix4x4.rb', line 339 def []=(row, column, value) end |
#column(index) ⇒ Array<Float>?
Returns the specified matrix column as an array.
193 194 |
# File 'lib/numerix/matrix4x4.rb', line 193 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).
169 170 |
# File 'lib/numerix/matrix4x4.rb', line 169 def determinant end |
#each_column {|column| ... } ⇒ self
Enumerates the columns of the matrix.
217 218 |
# File 'lib/numerix/matrix4x4.rb', line 217 def each_column end |
#each_row {|row| ... } ⇒ self
Enumerates the rows of the matrix.
see each_column
205 206 |
# File 'lib/numerix/matrix4x4.rb', line 205 def each_row end |
#identity? ⇒ Boolean
Returns true if the matrix is the identity matrix, otherwise
false.
159 160 |
# File 'lib/numerix/matrix4x4.rb', line 159 def identity? end |
#invert ⇒ Matrix4x4
Some matrices cannot be inverted, in which case the returned matrix
will have all values set to NaN.
Attempts to invert the given matrix.
349 350 |
# File 'lib/numerix/matrix4x4.rb', line 349 def invert end |
#lerp(matrix, amount) ⇒ Matrix4x4
Linearly interpolates from this matrix to another, based on the amount.
230 231 |
# File 'lib/numerix/matrix4x4.rb', line 230 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.
246 247 |
# File 'lib/numerix/matrix4x4.rb', line 246 def lerp!(matrix, amount) end |
#map {|component| ... } ⇒ Matrix4x4 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.
126 127 |
# File 'lib/numerix/matrix4x4.rb', line 126 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.
141 142 |
# File 'lib/numerix/matrix4x4.rb', line 141 def map! end |
#row(index) ⇒ Array<Float>?
Returns the specified matrix row as an array.
181 182 |
# File 'lib/numerix/matrix4x4.rb', line 181 def row(index) end |
#to_a ⇒ Array<Array<Float>> Also known as: elements
Returns an Array representation of this instance.
256 257 |
# File 'lib/numerix/matrix4x4.rb', line 256 def to_a end |
#to_h ⇒ Hash{Symbol => Float}
Returns a Hash representation of this instance.
263 264 |
# File 'lib/numerix/matrix4x4.rb', line 263 def to_h end |
#to_s ⇒ String
Returns a String representation of this instance.
251 252 |
# File 'lib/numerix/matrix4x4.rb', line 251 def to_s end |
#transform(rotation) ⇒ Matrix4x4
Creates a matrix by transforming this instance by applying the given quaternion rotation.
359 360 |
# File 'lib/numerix/matrix4x4.rb', line 359 def transform(rotation) end |
#transform!(rotation) ⇒ self
Transforms this matrix by applying the given quaternion rotation.
368 369 |
# File 'lib/numerix/matrix4x4.rb', line 368 def transform!(rotation) end |
#transpose ⇒ Matrix4x4
Transposes the rows and columns of a matrix.
375 376 |
# File 'lib/numerix/matrix4x4.rb', line 375 def transpose end |