module Geode::Matrix3x3Transforms3DConstructors(T)
Overview
Transformation that can be performed in three-dimensions with 3x3 matrices.
Multiplying a 3D object by the matrices produced by these methods will apply the operation to the object. The matrix must be on the right-hand-side of the multiplication operation.
object * matrix
Matrix multiplication is not commutative, therefore the ordering matters. If it's desired to have the matrix on the left-hand-side, transpose it before multiplying.
matrix.transpose * object
To combine multiple operations, multiply the matrices from these methods together.
This module should be extended.
Defined in:
geode/matrices/transforms3d.crInstance Method Summary
-
#reflect_x : self
Creates a 3D reflecting matrix.
-
#reflect_y : self
Creates a 3D reflective matrix.
-
#reflect_z : self
Creates a 3D reflecting matrix.
-
#rotate(angle : Number | Angle, axis : CommonVector(T, 3)) : self
Creates a 3D rotation matrix.
-
#rotate_x(angle : Number | Angle) : self
Creates a 3D rotation matrix.
-
#rotate_y(angle : Number | Angle) : self
Creates a 3D rotation matrix.
-
#rotate_z(angle : Number | Angle) : self
Creates a 3D rotation matrix.
-
#scale(x : T, y : T, z : T) : self
Creates a 3D scaling matrix.
-
#scale(amount : T) : self
Creates a 3D scaling matrix.
-
#shear_x(y : T, z : T) : self
Creates a 3D shearing matrix.
-
#shear_y(x : T, z : T) : self
Creates a 3D shearing matrix.
-
#shear_z(x : T, y : T) : self
Creates a 3D shearing matrix.
Instance Method Detail
Creates a 3D reflecting matrix.
Multiplying a 3D object by this matrix will reflect it along the x-axis.
vector = Vector3[1, 2, 3]
matrix = Matrix3(Int32).reflect_x
vector * matrix # => (-1, 2, 3)
Creates a 3D reflective matrix.
Multiplying a 3D object by this matrix will reflect it along the y-axis.
vector = Vector3[1, 2, 3]
matrix = Matrix3(Int32).reflect_y
vector * matrix # => (1, -2, 3)
Creates a 3D reflecting matrix.
Multiplying a 3D object by this matrix will reflect it along the z-axis.
vector = Vector3[1, 2, 3]
matrix = Matrix3(Int32).reflect_z
vector * matrix # => (1, 2, -3)
Creates a 3D rotation matrix.
Multiplying a 3D object by this matrix will rotate it the specified amount.
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).rotate(45.degrees, axis)
vector * matrix # => (1.701141509, 1.183503419, 3.115355072)
Creates a 3D rotation matrix.
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).rotate_x(45.degrees)
vector * matrix # => (1.0, 0.0, 1.414213562)
Creates a 3D rotation matrix.
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).rotate_y(45.degrees)
vector * matrix # => (1.414213562, 1.0, 0.0)
Creates a 3D rotation matrix.
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).rotate_z(45.degrees)
vector * matrix # => (0.0, 1.414213562, 1.0)
Creates a 3D scaling matrix.
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).scale(1.5, 2, 2.5)
vector * matrix # => (3.0, 6.0, 9.0)
Creates a 3D scaling matrix.
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).scale(2)
vector * matrix # => (4, 6, 8)
Creates a 3D shearing matrix.
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).shear_x(2, 3)
vector * matrix # => (2, 7, 10)
Creates a 3D shearing matrix.
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).shear_y(2, 3)
vector * matrix # => (8, 3, 13)
Creates a 3D shearing matrix.
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).shear_z(2, 3)
vector * matrix # => (10, 15, 4)