Chem::Spatial::Mat3
Inherits Struct / Value / Object
A 3x3 matrix in row-major order. This is useful for encoding linear
maps such as scaling and rotation (see Transform).
Constructors
Creates a new Mat3, allocating an internal buffer, and yielding
that buffer to the passed block.
This method is unsafe, but is usually used to initialize the buffer by other convenience methods without doing bounds check.
Returns a new matrix with the elements at the diagonal set to the given values.
Reads a matrix from io in the given format. See also:
IO#read_bytes.
Class methods
Returns a matrix in column-major order representing the basis defined by the basis vectors.
Instance methods
Returns the row at row. Raises IndexError if row is out of
bounds.
Returns the column at col. Raises IndexError if col is out
of bounds.
Returns the element at the given row and column. Raises
IndexError if indices are out of bounds.
Returns true if the elements of the matrices are within delta
from each other, else false.
Returns the inverse matrix. Raises ArgumentError if the matrix
is not invertible.
The inverse matrix is computed using the Cramer's rule, which
states that inv(A) = 1 / det(A) * adj(A) provided that det(A) != 0.
Writes the binary representation of the matrix to io in the
given format. See also IO#write_bytes.
Returns the element at row and col, without doing any bounds check.
This should be called with row and col within 0...3. Use
#[](i, j) and #[]?(i, j) instead for bounds checking and
support for negative indexes.
NOTE: This method should only be directly invoked if you are absolutely sure row and col are within bounds, to avoid a bounds check for a small boost of performance.
Returns the element at the given index , without doing any bounds check.
NOTE: This method should only be directly invoked if you are absolutely sure the index is within bounds, to avoid a bounds check for a small boost of performance.
Macros
Returns a new 3x3 matrix using a matrix literal, i.e., three indexable (array or tuple) literals.
Mat3[[1, 2, 3], [4, 5, 6], [7, 8, 9]]