module Geode::Matrix3x3Transforms2D(T)
Overview
Transformation that can be performed in twodimensions with 3x3 matrices.
These methods produce a new matrix that has the operation performed on it. This:
matrix.rotate_x(45.degrees)
is effectively the same as:
matrix * Matrix3(Float64).rotate_x(45.degrees)
Direct including types
Defined in:
geode/matrices/transforms2d.crInstance Method Summary

#reflect_x : self
Returns a matrix that has a reflection transform applied.

#reflect_xy : self
Returns a matrix that has a scale transform applied.

#reflect_y : self
Returns a matrix that has a scale transform applied.

#rotate(angle : Number  Angle) : CommonMatrix
Returns a matrix that has a 2D rotation transform applied.

#rotate180 : self
Returns a matrix that has a 180degree rotation transform applied.

#rotate270 : self
Returns a matrix that has a 270degree rotation transform applied.

#rotate90 : self
Returns a matrix that has a 90degree rotation transform applied.

#scale(x, y) : CommonMatrix
Returns a matrix that has a scale transform applied.

#scale2(amount : Number) : CommonMatrix
Returns a matrix that has a scale transform applied.

#shear_x(amount) : CommonMatrix
Returns a matrix that has a shear transform applied.

#shear_y(amount : T) : self
Returns a matrix that has a shear transform applied.

#translate(x, y) : CommonMatrix
Returns a matrix that has a translation applied.
Instance Method Detail
Returns a matrix that has a reflection transform applied.
Returns a 3x3 matrix. Multiplying a 2D object by this matrix will reflect it along the xaxis.
vector = Vector3[5, 1, 1]
matrix = Matrix3(Int32).identity.reflect_x
vector * matrix # => (5, 1, 1)
Returns a matrix that has a scale transform applied.
Returns a 3x3 matrix. Multiplying a 2D object by this matrix will reflect it along the x and yaxis. This has the same effect as rotating 180 degrees.
vector = Vector3[5, 1, 1]
matrix = Matrix3(Int32).identity.reflect_xy
vector * matrix # => (5, 1, 1)
See: #rotate270
Returns a matrix that has a scale transform applied.
Returns a 3x3 matrix. Multiplying a 2D object by this matrix will reflect it along the yaxis.
vector = Vector3[5, 1, 1]
matrix = Matrix3(Int32).identity.reflect_y
vector * matrix # => (5, 1, 1)
Returns a matrix that has a 2D rotation transform applied.
Returns a 3x3 matrix.
The angle must be a Number
in radians or an Angle
.
vector = Vector3[3 / 5, 4 / 5, 1]
matrix = Matrix3(Float64).identity.rotate(45.degrees)
vector * matrix # => (0.0, 1.0, 1.0)
Returns a matrix that has a 180degree rotation transform applied.
Returns a 3x3 matrix. Multiplying a 2D object by this matrix will rotate it 180 degrees.
vector = Vector3[1, 1, 1]
matrix = Matrix3(Int32).identity.rotate180
vector * matrix # => (1, 1, 1)
Returns a matrix that has a 270degree rotation transform applied.
Returns a 3x3 matrix. Multiplying a 2D object by this matrix will rotate it 270 degrees.
vector = Vector3[1, 1, 1]
matrix = Matrix3(Int32).identity.rotate270
vector * matrix # => (1, 1, 1)
See: #reflect_xy
Returns a matrix that has a 90degree rotation transform applied.
Returns a 3x3 matrix. Multiplying a 2D object by this matrix will rotate it 90 degrees.
vector = Vector3[1, 1, 1]
matrix = Matrix3(Int32).identity.rotate90
vector * matrix # => (1, 1, 1)
Returns a matrix that has a scale transform applied.
Returns a 3x3 matrix.
Nonuniformly scales an object (squash and stretch). Values for x and y smaller than 1 will shrink it. Values larger than 1 will enlarge it. Negative values will flip it.
vector = Vector3[2, 3, 1]
matrix = Matrix3(Float64).identity.scale(1.5, 2)
vector * matrix # => (3.0, 6.0, 1.0)
Returns a matrix that has a scale transform applied.
Returns a 3x3 matrix.
Uniformly scales an object. Multiplying a 2D object by this matrix will scale it by amount. Values for amount smaller than 1 will shrink it. Values larger than 1 will enlarge it. Negative values will flip it.
vector = Vector3[2, 3, 1]
matrix = Matrix3(Int32).identity.scale2(2)
vector * matrix # => (4, 6, 1)
Returns a matrix that has a shear transform applied.
Returns a 3x3 matrix. Multiplying a 2D object by this matrix will shear it along the xaxis.
vector = Vector3[2, 3, 1]
matrix = Matrix3(Int32).identity.shear_x(2)
vector * matrix # => (8, 3, 1)
Returns a matrix that has a shear transform applied.
Returns a 3x3 matrix. Multiplying a 2D object by this matrix will shear it along the yaxis.
vector = Vector3[2, 3, 1]
matrix = Matrix3(Int32).identity.shear_y(2)
vector * matrix # => (2, 7, 1)
Returns a matrix that has a translation applied.
Returns a 3x3 matrix.
vector = Vector3[3, 5, 1]
matrix = Matrix3(Int32).identity.translate(1, 2)
vector * matrix # => (4, 7, 1)