module Geode::Matrix4x4Transforms3DConstructors(T)
Overview
Transformation that can be performed in threedimensions with 4x4 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 righthandside 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 lefthandside, 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

#look_at(eye : CommonVector(T, 3), target : CommonVector(T, 3), up : CommonVector(T, 3)) : self
Creates a 3D view matrix oriented to look at a point.

#look_at_lh(eye : CommonVector(T, 3), target : CommonVector(T, 3), up : CommonVector(T, 3)) : self
Creates a 3D view matrix oriented to look at a point.

#look_at_rh(eye : CommonVector(T, 3), target : CommonVector(T, 3), up : CommonVector(T, 3)) : self
Creates a 3D view matrix oriented to look at a point.

#reflect_x : self
Creates a 3D reflecting matrix with space for translation.

#reflect_y : self
Creates a 3D reflective matrix with space for translation.

#reflect_z : self
Creates a 3D reflecting matrix with space for translation.

#rotate(angle : Number  Angle, axis : CommonVector(T, 3)) : self
Creates a 3D rotation matrix with space for translation.

#rotate_x(angle : Number  Angle) : self
Creates a 3D rotation matrix with space for translation.

#rotate_y(angle : Number  Angle) : self
Creates a 3D rotation matrix with space for translation.

#rotate_z(angle : Number  Angle) : self
Creates a 3D rotation matrix with space for translation.

#scale(x : T, y : T, z : T) : self
Creates a 3D scaling matrix with space for translation.

#scale(amount : T) : self
Creates a 3D scaling matrix with space for translation.

#shear_x(y : T, z : T) : self
Creates a 3D shearing matrix with space for translation.

#shear_y(x : T, z : T) : self
Creates a 3D shearing matrix with space for translation.

#shear_z(x : T, y : T) : self
Creates a 3D shearing matrix with space for translation.

#translate(x : T, y : T, z : T) : self
Creates a 3D transform matrix.
Instance Method Detail
Creates a 3D view matrix oriented to look at a point.
The eye is the position of the camera. target is the point being looked at. The up vector indicates which direction is "up" for the camera.
The handedness is controlled by compiler flags.
Righthanded orientation is the default (common in OpenGL).
Specify Dleft_handed
to use a lefthanded system.
Matrix4F.look_at(Vector3F[1, 2, 3], Vector3F[0, 0, 0].Vector3F[0, 1, 0])
TODO Support Point
types for eye and target.
Creates a 3D view matrix oriented to look at a point.
The eye is the position of the camera. target is the point being looked at. The up vector indicates which direction is "up" for the camera.
The matrix produced is for lefthanded systems.
Matrix4F.look_at(Vector3F[1, 2, 3], Vector3F[0, 0, 0].Vector3F[0, 1, 0])
TODO Support Point
types for eye and target.
Creates a 3D view matrix oriented to look at a point.
The eye is the position of the camera. target is the point being looked at. The up vector indicates which direction is "up" for the camera.
The matrix produced is for righthanded systems.
Matrix4F.look_at(Vector3F[1, 2, 3], Vector3F[0, 0, 0].Vector3F[0, 1, 0])
TODO Support Point
types for eye and target.
Creates a 3D reflecting matrix with space for translation.
Multiplying an object by this matrix will reflect it along the xaxis.
vector = Vector4[1, 2, 3, 1]
matrix = Matrix4(Int32).reflect_x
vector * matrix # => (1, 2, 3, 1)
Creates a 3D reflective matrix with space for translation.
Multiplying an object by this matrix will reflect it along the yaxis.
vector = Vector4[1, 2, 3, 1]
matrix = Matrix4(Int32).reflect_y
vector * matrix # => (1, 2, 3, 1)
Creates a 3D reflecting matrix with space for translation.
Multiplying an object by this matrix will reflect it along the zaxis.
vector = Vector4[1, 2, 3, 1]
matrix = Matrix4(Int32).reflect_z
vector * matrix # => (1, 2, 3, 1)
Creates a 3D rotation matrix with space for translation.
Multiplying an 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 = Vector4[1, 2, 3, 1]
matrix = Matrix4(Float64).rotate(45.degrees, axis)
vector * matrix # => (1.701141509, 1.183503419, 3.115355072, 1.0)
Creates a 3D rotation matrix with space for translation.
Multiplying an object by this matrix will rotate it around the xaxis.
The angle must be a Number
in radians or an Angle
.
vector = Vector4[1, 1, 1, 1]
matrix = Matrix4(Float64).rotate_x(45.degrees)
vector * matrix # => (1.0, 0.0, 1.414213562, 1.0)
Creates a 3D rotation matrix with space for translation.
Multiplying an object by this matrix will rotate it around the yaxis.
The angle must be a Number
in radians or an Angle
.
vector = Vector4[1, 1, 1, 1]
matrix = Matrix4(Float64).rotate_y(45.degrees)
vector * matrix # => (1.414213562, 1.0, 0.0, 1.0)
Creates a 3D rotation matrix with space for translation.
Multiplying an object by this matrix will rotate it around the zaxis.
The angle must be a Number
in radians or an Angle
.
vector = Vector4[1, 1, 1, 1]
matrix = Matrix4(Float64).rotate_z(45.degrees)
vector * matrix # => (0.0, 1.414213562, 1.0, 1.0)
Creates a 3D scaling matrix with space for translation.
Nonuniformly scales an object (squash and stretch). Multiplying an object by this matrix will scale it by x amount along the xaxis and y amount along the yaxis. Values for x and y smaller than 1 will shrink it. Values larger than 1 will enlarge it. Negative values will flip it.
vector = Vector4[2, 3, 4, 1]
matrix = Matrix4(Float64).scale(1.5, 2, 2.5)
vector * matrix # => (3.0, 6.0, 9.0, 1.0)
Creates a 3D scaling matrix with space for translation.
Uniformly scales an object. Multiplying an 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 = Vector4[2, 3, 4, 1]
matrix = Matrix4(Float64).scale(2)
vector * matrix # => (4.0, 6.0, 8.0, 1.0)
Creates a 3D shearing matrix with space for translation.
Multiplying an object by this matrix will shear it along the y and zaxis based on the xaxis. For each unit along the xaxis, the y value will be adjusted by y and the z value will be adjusted by z.
vector = Vector4[2, 3, 4, 1]
matrix = Matrix4(Int32).shear_x(2, 3)
vector * matrix # => (2, 7, 10, 1)
Creates a 3D shearing matrix with space for translation.
Multiplying an object by this matrix will shear it along the x and zaxis based on the yaxis. For each unit along the yaxis, the x value will be adjusted by x and the z value will be adjusted by z.
vector = Vector4[2, 3, 4, 1]
matrix = Matrix4(Int32).shear_y(2, 3)
vector * matrix # => (8, 3, 13, 1)
Creates a 3D shearing matrix with space for translation.
Multiplying an object by this matrix will shear it along the x and yaxis based on the zaxis. For each unit along the zaxis, the x value will be adjusted by x and the y value will be adjusted by y.
vector = Vector4[2, 3, 4, 1]
matrix = Matrix4(Int32).shear_z(2, 3)
vector * matrix # => (10, 15, 4, 1)
Creates a 3D transform matrix.
vector = Vector4[3, 5, 7, 1]
matrix = Matrix4(Int32).translate(3, 2, 1)
vector * matrix # => (6, 7, 8, 1)