3×4 matrix (3 rows, 4 columns) used for 3D linear transformations.
It can represent transformations such as translation, rotation, or scaling.
It consists of a godot.Basis
(first 3 columns) and a
godot.Vector3
for the origin (last column).
For more information, read this documentation article: https://docs.godotengine.org/en/3.4/tutorials/math/matrices_and_transforms.html
Static variables
staticread onlyFLIP_X:Transform
The transform that will flip something along the X axis.
Value: Equivalent to new Transform(Vector3.Left, Vector3.Up, Vector3.Back, Vector3.Zero)
.
staticread onlyFLIP_Y:Transform
The transform that will flip something along the Y axis.
Value: Equivalent to new Transform(Vector3.Right, Vector3.Down, Vector3.Back, Vector3.Zero)
.
staticread onlyFLIP_Z:Transform
The transform that will flip something along the Z axis.
Value: Equivalent to new Transform(Vector3.Right, Vector3.Up, Vector3.Forward, Vector3.Zero)
.
staticread onlyIDENTITY:Transform
The identity transform, with no translation, rotation, or scaling applied.
This is used as a replacement for Transform()
in GDScript.
Do not use new Transform()
with no arguments in C#, because it sets all values to zero.
Value: Equivalent to new Transform(Vector3.Right, Vector3.Up, Vector3.Back, Vector3.Zero)
.
Static methods
staticinlineop_Equality(left:Transform, right:Transform):Bool
Operator overload for godot.Transform
== godot.Transform
.
staticinlineop_Inequality(left:Transform, right:Transform):Bool
Operator overload for godot.Transform
!= godot.Transform
.
staticinlineop_Multiply(left:Transform, right:Transform):Transform
Operator overload for godot.Transform
* godot.Transform
.
Constructor
new(column0:Vector3, column1:Vector3, column2:Vector3, origin:Vector3)
new(basis:Basis, origin:Vector3)
new(quaternion:Quat, origin:Vector3)
Constructs a transformation matrix from 4 vectors (matrix columns).
Parameters:
column0 | The X vector, or column index 0. |
---|---|
column1 | The Y vector, or column index 1. |
column2 | The Z vector, or column index 2. |
origin | The origin vector, or column index 3. |
Variables
basis:Basis
The godot.Basis
of this transform. Contains the X, Y, and Z basis
vectors (columns 0 to 2) and is responsible for rotation and scale.
Methods
affineInverse():Transform
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling, and translation.
Returns:
The inverse transformation matrix.
See also:
interpolateWith(transform:Transform, weight:Single):Transform
Interpolates this transform to the other transform
by weight
.
Parameters:
transform | The other transform. |
---|---|
weight | A value on the range of 0.0 to 1.0, representing the amount of interpolation. |
Returns:
The interpolated transform.
inverse():Transform
Returns the inverse of the transform, under the assumption that
the transformation is composed of rotation and translation
(no scaling, use godot.Transform.affineInverse
for transforms with scaling).
Returns:
The inverse matrix.
isEqualApprox(other:Transform):Bool
Returns true
if this transform and other
are approximately equal,
by running godot.Vector3.isEqualApprox
on each component.
Parameters:
other | The other transform to compare. |
---|
Returns:
Whether or not the matrices are approximately equal.
lookingAt(target:Vector3, up:Vector3):Transform
Returns a copy of the transform rotated such that its
-Z axis (forward) points towards the target
position.
The transform will first be rotated around the given up
vector,
and then fully aligned to the target
by a further rotation around
an axis perpendicular to both the target
and up
vectors.
Operations take place in global space.
Parameters:
target | The object to look at. |
---|---|
up | The relative up direction |
Returns:
The resulting transform.
orthonormalized():Transform
Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
Returns:
The orthonormalized transform.
rotated(axis:Vector3, phi:Single):Transform
Rotates the transform around the given axis
by phi
(in radians),
using matrix multiplication. The axis must be a normalized vector.
Parameters:
axis | The axis to rotate around. Must be normalized. |
---|---|
phi | The angle to rotate, in radians. |
Returns:
The rotated transformation matrix.
scaled(scale:Vector3):Transform
Scales the transform by the given 3D scaling factor, using matrix multiplication.
Parameters:
scale | The scale to introduce. |
---|
Returns:
The scaled transformation matrix.
translated(offset:Vector3):Transform
Translates the transform by the given offset
,
relative to the transform's basis vectors.
Unlike godot.Transform.rotated
and godot.Transform.scaled
,
this does not use matrix multiplication.
Parameters:
offset | The offset to translate by. |
---|
Returns:
The translated matrix.
xform(v:Vector3):Vector3
Returns a vector transformed (multiplied) by this transformation matrix.
Parameters:
v | A vector to transform. |
---|
Returns:
The transformed vector.
See also:
xformInv(v:Vector3):Vector3
Returns a vector transformed (multiplied) by the transposed transformation matrix.
Note: This results in a multiplication by the inverse of the transformation matrix only if it represents a rotation-reflection.
Parameters:
v | A vector to inversely transform. |
---|
Returns:
The inversely transformed vector.
See also: