class CrystalEdge::Matrix(T, H, W)

Overview

Column major matrix

Included Modules

Defined in:

crystaledge/matrix.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(value : T) #

Initializes matrix filled with value


[View source]
def self.new(matrix : Slice(T)) #

Initializes a matrix with a Slice of elements


[View source]
def self.new #

Initializes an empty matrix


[View source]
def self.new(&block : Int32, Int32 -> T) #

Initializes matrix using a block called with row and column number


[View source]

Class Method Detail

def self.identity #

[View source]
def self.rotation(*values) #

Makes a new rotation matrix

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


[View source]
def self.scaling(*values) #

Makes a new scaling matrix

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


[View source]
def self.translation(*values) #

Makes a new translation matrix

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


[View source]

Instance Method Detail

def !=(other) #

Tests matrices for inequality


[View source]
def *(other : Matrix(T, W, U)) forall U #

Calculates the product of two matrices


[View source]
def *(other : Number) #

Performs multiplication by number


[View source]
def +(other : self) #

Performs addition of two matrices


[View source]
def -(other : self) #

Performs subtraction of two matrices


[View source]
def /(other : Number) #

Performs division by number


[View source]
def ==(other) #

Tests matrices for equality


[View source]
def [](r, c) #

Gets an element by row and column numbers


[View source]
def [](i : Int) #

Gets an element by index


[View source]
def []=(r, c, v : T) #

Sets an element by row and column numbers


[View source]
def []=(i, v : T) #

Sets an element by index


[View source]
def []?(r, c) #

ditto


[View source]
def []?(i : Int) #

ditto


[View source]
def clone #

Clones matrix


[View source]
def copy_from(m : self) #

Copies contents of m into this matrix


[View source]
def copy_to(m : self) #

Copies contents of this matrix into m


[View source]
def each(*args, **options) #

[View source]
def each(*args, **options, &) #

[View source]
def height #

Returns height (number of rows)


[View source]
def index(r, c) #

Calculates index from row and column numbers


[View source]
def make_rotation(*values) #

Cloning version of #make_rotation!


[View source]
def 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


[View source]
def make_scaling(*values) #

Cloning version of #make_scaling!


[View source]
def make_scaling!(vec) #

ditto


[View source]
def make_scaling!(*values : T) #

Make scaling matrix from a zero-filled one.

This method changes current object


[View source]
def make_translation(*values) #

Cloning version of #make_translation!


[View source]
def make_translation!(vec) #

ditto


[View source]
def make_translation!(*values : T) #

Make translation matrix from a zero-filled one.

This method changes current object


[View source]
def matrix #

[View source]
def matrix=(matrix : Slice(T)) #

[View source]
def rotate(*values) #

Rotates matrix


[View source]
def rotate!(*values) #

Rotates this matrix

Changes the value of current matrix.


[View source]
def scale(*values) #

Scales matrix


[View source]
def scale!(*values) #

Scales this matrix

Changes the value of current matrix.


[View source]
def size #

Returns size of square matrix

Raises if matrix is not square


[View source]
def submatrix(x, y, m : Matrix(T, M, N).class) forall M, N #

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


[View source]
def to_s(io) #

Return string representation of the matrix


[View source]
def to_unsafe(*args, **options) #

[View source]
def to_unsafe(*args, **options, &) #

[View source]
def translate(*values) #

Translates matrix


[View source]
def translate!(*values) #

Translates this matrix

Changes the value of current matrix.


[View source]
def transpose : Matrix(T, W, H) #

Transposes a matrix


[View source]
def transpose! : self #

Transposes a matrix.

This method changes the object

Raises if current matrix is not square


[View source]
def unsafe_fetch(idx : Int) #
Description copied from module Indexable(T)

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.


[View source]
def width #

Returns width (number of columns)


[View source]