class

CrystalEdge::Matrix(T, H, W)

Inherits Indexable < Enumerable < Iterable < Enumerable < Reference < Object

Column major matrix

Constructors

new(value : T)

Initializes matrix filled with value

Source
new(matrix : Slice(T))

Initializes a matrix with a Slice of elements

Source
new

Initializes an empty matrix

Source
new

Initializes matrix using a block called with row and column number

Source

Class methods

identity
Source
rotation(*values)

Makes a new rotation matrix

Can be called with one Vector2 or Vector3, like #make_rotation!

Source
scaling(*values)

Makes a new scaling matrix

Can be called with one Vector2 or Vector3, like #make_scaling!

Source
translation(*values)

Makes a new translation matrix

Can be called with one Vector2 or Vector3, like #make_translation!

Source

Instance methods

!=(other)

Tests matrices for inequality

Source
*(other : Matrix(T, W, U)) forall U

Calculates the product of two matrices

Source
*(other : Number)

Performs multiplication by number

Source
+(other : self)

Performs addition of two matrices

Source
-(other : self)

Performs subtraction of two matrices

Source
/(other : Number)

Performs division by number

Source
==(other)

Tests matrices for equality

Source
[](r, c)

Gets an element by row and column numbers

Source
[](i : Int)

Gets an element by index

Source
[]=(r, c, v : T)

Sets an element by row and column numbers

Source
[]=(i, v : T)

Sets an element by index

Source
[]?(r, c)

ditto

Source
[]?(i : Int)

ditto

Source
clone

Clones matrix

Source
copy_from(m : self)

Copies contents of m into this matrix

Source
copy_to(m : self)

Copies contents of this matrix into m

Source
each(*args, **options)
Source
each(*args, **options, &)
Source
height

Returns height (number of rows)

Source
index(r, c)

Calculates index from row and column numbers

Source
make_rotation(*values)

Cloning version of #make_rotation!

Source
make_rotation!(*values : T)

Make rotation matrix from a zero-filled one.

This method changes current object.

Can be called with one of four values:

# 2D rotation
matrix.make_rotation! theta

# 3D rotation by angle theta around axis represented by unit vector {l, m, n}
matrix.make_rotation! theta, l, m, n

Raises if called with other number of arguments

Source
make_scaling(*values)

Cloning version of #make_scaling!

Source
make_scaling!(vec)

ditto

Source
make_scaling!(*values : T)

Make scaling matrix from a zero-filled one.

This method changes current object

Source
make_translation(*values)

Cloning version of #make_translation!

Source
make_translation!(vec)

ditto

Source
make_translation!(*values : T)

Make translation matrix from a zero-filled one.

This method changes current object

Source
matrix
Source
matrix=(matrix : Slice(T))
Source
rotate(*values)

Rotates matrix

Source
rotate!(*values)

Rotates this matrix

Changes the value of current matrix.

Source
scale(*values)

Scales matrix

Source
scale!(*values)

Scales this matrix

Changes the value of current matrix.

Source
size

Returns size of square matrix

Raises if matrix is not square

Source
submatrix(x, y, m : Matrix(T, M, N).class) forall M, N

Returns submatrix of type m (size MxN) with offset x, y

Source
to_s(io)

Return string representation of the matrix

Source
to_unsafe(*args, **options)
Source
to_unsafe(*args, **options, &)
Source
translate(*values)

Translates matrix

Source
translate!(*values)

Translates this matrix

Changes the value of current matrix.

Source
transpose

Transposes a matrix

Source
transpose!

Transposes a matrix.

This method changes the object

Raises if current matrix is not square

Source
unsafe_fetch(idx : Int)

Returns the element at the given index, without doing any bounds check.

Indexable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they access elements with #[](index) and #[]?(index).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.

Source
width

Returns width (number of columns)

Source