class CrystalEdge::Matrix(T, H, W)
- CrystalEdge::Matrix(T, H, W)
- Reference
- Object
Overview
Column major matrix
Included Modules
- Enumerable(T)
- Indexable(T)
Defined in:
crystaledge/matrix.crConstructors
-
.new(value : T)
Initializes matrix filled with
value
-
.new(matrix : Slice(T))
Initializes a matrix with a Slice of elements
-
.new
Initializes an empty matrix
-
.new(&block : Int32, Int32 -> T)
Initializes matrix using a block called with row and column number
Class Method Summary
- .identity
-
.rotation(*values)
Makes a new rotation matrix
-
.scaling(*values)
Makes a new scaling matrix
-
.translation(*values)
Makes a new translation matrix
Instance Method Summary
-
#!=(other)
Tests matrices for inequality
-
#*(other : Matrix(T, W, U)) forall U
Calculates the product of two matrices
-
#*(other : Number)
Performs multiplication by number
-
#+(other : self)
Performs addition of two matrices
-
#-(other : self)
Performs subtraction of two matrices
-
#/(other : Number)
Performs division by number
-
#==(other)
Tests matrices for equality
-
#[](r, c)
Gets an element by row and column numbers
-
#[](i : Int)
Gets an element by index
-
#[]=(r, c, v : T)
Sets an element by row and column numbers
-
#[]=(i, v : T)
Sets an element by index
-
#[]?(r, c)
ditto
-
#[]?(i : Int)
ditto
-
#clone
Clones matrix
-
#copy_from(m : self)
Copies contents of
m
into this matrix -
#copy_to(m : self)
Copies contents of this matrix into
m
- #each(*args, **options)
- #each(*args, **options, &)
-
#height
Returns height (number of rows)
-
#index(r, c)
Calculates index from row and column numbers
-
#make_rotation(*values)
Cloning version of
#make_rotation!
-
#make_rotation!(*values : T)
Make rotation matrix from a zero-filled one.
-
#make_scaling(*values)
Cloning version of
#make_scaling!
-
#make_scaling!(vec)
ditto
-
#make_scaling!(*values : T)
Make scaling matrix from a zero-filled one.
-
#make_translation(*values)
Cloning version of
#make_translation!
-
#make_translation!(vec)
ditto
-
#make_translation!(*values : T)
Make translation matrix from a zero-filled one.
- #matrix
- #matrix=(matrix : Slice(T))
-
#rotate(*values)
Rotates matrix
-
#rotate!(*values)
Rotates this matrix
-
#scale(*values)
Scales matrix
-
#scale!(*values)
Scales this matrix
-
#size
Returns size of square matrix
-
#submatrix(x, y, m : Matrix(T, M, N).class) forall M, N
Returns submatrix of type
m
(sizeM
xN
) with offsetx
,y
-
#to_s(io)
Return string representation of the matrix
- #to_unsafe(*args, **options)
- #to_unsafe(*args, **options, &)
-
#translate(*values)
Translates matrix
-
#translate!(*values)
Translates this matrix
-
#transpose : Matrix(T, W, H)
Transposes a matrix
-
#transpose! : self
Transposes a matrix.
-
#unsafe_fetch(idx : Int)
Returns the element at the given index, without doing any bounds check.
-
#width
Returns width (number of columns)
Constructor Detail
Initializes matrix using a block called with row and column number
Class Method Detail
Makes a new rotation matrix
Can be called with one Vector2 or Vector3, like #make_rotation!
Makes a new scaling matrix
Can be called with one Vector2 or Vector3, like #make_scaling!
Makes a new translation matrix
Can be called with one Vector2 or Vector3, like #make_translation!
Instance Method Detail
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
Make scaling matrix from a zero-filled one.
This method changes current object
Make translation matrix from a zero-filled one.
This method changes current object
Returns submatrix of type m
(size M
xN
) with offset x
, y
Transposes a matrix.
This method changes the object
Raises if current matrix is not square
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.