module Geode::Matrix3x3Transforms3D(T)
Overview
Transformation that can be performed in three-dimensions 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/transforms3d.crInstance Method Summary
-
#reflect_x : self
Returns a matrix that has a reflection transform applied.
-
#reflect_y : self
Returns a matrix that has a reflection transform applied.
-
#reflect_z : self
Returns a matrix that has a reflection transform applied.
-
#rotate(angle : Number | Angle, axis : CommonVector(U, 3)) : CommonMatrix forall U
Returns a matrix that has a rotation transform applied.
-
#rotate_x(angle : Number | Angle) : CommonMatrix
Returns a matrix that has a rotation transform applied.
-
#rotate_y(angle : Number | Angle) : CommonMatrix
Returns a matrix that has a rotation transform applied.
-
#rotate_z(angle : Number | Angle) : CommonMatrix
Returns a matrix that has a rotation transform applied.
-
#scale(x, y, z) : CommonMatrix
Returns a matrix that has a scale transform applied.
-
#scale(amount : Number) : CommonMatrix
Returns a matrix that has a scale transform applied.
-
#shear_x(y, z) : CommonMatrix
Returns a matrix that has a shear transform applied.
-
#shear_y(x, z) : CommonMatrix
Returns a matrix that has a shear transform applied.
-
#shear_z(x, y) : CommonMatrix
Returns a matrix that has a shear transform applied.
-
#translate(x, y, z) : CommonMatrix
Returns a matrix with a translation applied.
Instance Method Detail
Returns a matrix that has a reflection transform applied.
Multiplying a 3D object by this matrix will reflect it along the x-axis.
vector = Vector3[1, 2, 3]
matrix = Matrix3(Int32).identity.reflect_x
vector * matrix # => (-1, 2, 3)
Returns a matrix that has a reflection transform applied.
Multiplying a 3D object by this matrix will reflect it along the y-axis.
vector = Vector3[1, 2, 3]
matrix = Matrix3(Int32).identity.reflect_y
vector * matrix # => (1, -2, 3)
Returns a matrix that has a reflection transform applied.
Multiplying a 3D object by this matrix will reflect it along the z-axis.
vector = Vector3[1, 2, 3]
matrix = Matrix3(Int32).identity.reflect_z
vector * matrix # => (1, 2, -3)
Returns a matrix that has a rotation transform applied.
The angle must be a Number
in radians or an Angle
.
The object is rotated around the specified axis.
axis = Vector3[1, 1, 1].normalize
vector = Vector3[1, 2, 3]
matrix = Matrix3(Float64).identity.rotate(45.degrees, axis)
vector * matrix # => (1.701141509, 1.183503419, 3.115355072)
Returns a matrix that has a rotation transform applied.
Multiplying a 3D object by this matrix will rotate it around the x-axis.
The angle must be a Number
in radians or an Angle
.
vector = Vector3[1, 1, 1]
matrix = Matrix3(Float64).identity.rotate_x(45.degrees)
vector * matrix # => (1.0, 0.0, 1.414213562)
Returns a matrix that has a rotation transform applied.
Multiplying a 3D object by this matrix will rotate it around the y-axis.
The angle must be a Number
in radians or an Angle
.
vector = Vector3[1, 1, 1]
matrix = Matrix3(Float64).identity.rotate_y(45.degrees)
vector * matrix # => (1.414213562, 1.0, 0.0)
Returns a matrix that has a rotation transform applied.
Multiplying a 3D object by this matrix will rotate it around the z-axis.
The angle must be a Number
in radians or an Angle
.
vector = Vector3[1, 1, 1]
matrix = Matrix3(Float64).identity.rotate_z(45.degrees)
vector * matrix # => (0.0, 1.414213562, 1.0)
Returns a matrix that has a scale transform applied.
Non-uniformly scales an object (squash and stretch). Multiplying a 3D object by this matrix will scale it by x amount along the x-axis and y amount along the y-axis. 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, 4]
matrix = Matrix3(Float64).identity.scale(1.5, 2, 2.5)
vector * matrix # => (3.0, 6.0, 9.0)
Returns a matrix that has a scale transform applied.
Uniformly scales an object. Multiplying a 3D 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, 4]
matrix = Matrix3(Int32).identity.scale(2)
vector * matrix # => (4, 6, 8)
Returns a matrix that has a shear transform applied.
Multiplying a 3D object by this matrix will shear it along the y and z-axis based on the x-axis. For each unit along the x-axis, the y value will be adjusted by y and the z value will be adjusted by z.
vector = Vector3[2, 3, 4]
matrix = Matrix3(Int32).identity.shear_x(2, 3)
vector * matrix # => (2, 7, 10)
Returns a matrix that has a shear transform applied.
Multiplying a 3D object by this matrix will shear it along the x and z-axis based on the y-axis. For each unit along the y-axis, the x value will be adjusted by x and the z value will be adjusted by z.
vector = Vector3[2, 3, 4]
matrix = Matrix3(Int32).identity.shear_y(2, 3)
vector * matrix # => (8, 3, 13)
Returns a matrix that has a shear transform applied.
Multiplying a 3D object by this matrix will shear it along the x and y-axis based on the z-axis. For each unit along the z-axis, the x value will be adjusted by x and the y value will be adjusted by y.
vector = Vector3[2, 3, 4]
matrix = Matrix3(Int32).identity.shear_z(2, 3)
vector * matrix # => (10, 15, 4)
Returns a matrix with a translation applied.
vector = Vector4[3, 5, 7, 1]
matrix = Matrix3(Int32).identity.translate(3, 2, 1)
vector * matrix # => (6, 7, 8, 1)