3×3 matrix used for 3D rotation and scale. Almost always used as an orthogonal basis for a Transform.
Contains 3 vector fields X, Y and Z as its columns, which are typically interpreted as the local basis vectors of a 3D transformation. For such use, it is composed of a scaling and a rotation matrix, in that order (M = R.S).
Can also be accessed as array of 3D vectors. These vectors are normally orthogonal to each other, but are not necessarily normalized (due to scaling).
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:Basis
The basis that will flip something along the X axis when used in a transformation.
Value: Equivalent to new Basis(Vector3.Left, Vector3.Up, Vector3.Back)
.
staticread onlyFLIP_Y:Basis
The basis that will flip something along the Y axis when used in a transformation.
Value: Equivalent to new Basis(Vector3.Right, Vector3.Down, Vector3.Back)
.
staticread onlyFLIP_Z:Basis
The basis that will flip something along the Z axis when used in a transformation.
Value: Equivalent to new Basis(Vector3.Right, Vector3.Up, Vector3.Forward)
.
staticread onlyIDENTITY:Basis
The identity basis, with no rotation or scaling applied.
This is used as a replacement for Basis()
in GDScript.
Do not use new Basis()
with no arguments in C#, because it sets all values to zero.
Value: Equivalent to new Basis(Vector3.Right, Vector3.Up, Vector3.Back)
.
Static methods
staticinlineop_Equality(left:Basis, right:Basis):Bool
Operator overload for godot.Basis
== godot.Basis
.
staticinlineop_Inequality(left:Basis, right:Basis):Bool
Operator overload for godot.Basis
!= godot.Basis
.
staticinlineop_Multiply(left:Basis, right:Basis):Basis
Operator overload for godot.Basis
* godot.Basis
.
Constructor
Variables
column0:Vector3
Column 0 of the basis matrix (the X vector).
Value: Equivalent to godot.Basis.x
and array index [0]
.
column1:Vector3
Column 1 of the basis matrix (the Y vector).
Value: Equivalent to godot.Basis.y
and array index [1]
.
column2:Vector3
Column 2 of the basis matrix (the Z vector).
Value: Equivalent to godot.Basis.z
and array index [2]
.
row0:Vector3
Row 0 of the basis matrix. Shows which vectors contribute to the X direction. Rows are not very useful for user code, but are more efficient for some internal calculations.
row1:Vector3
Row 1 of the basis matrix. Shows which vectors contribute to the Y direction. Rows are not very useful for user code, but are more efficient for some internal calculations.
row2:Vector3
Row 2 of the basis matrix. Shows which vectors contribute to the Z direction. Rows are not very useful for user code, but are more efficient for some internal calculations.
scale:Vector3
The scale of this basis.
Value: Equivalent to the lengths of each column vector, but negative if the determinant is negative.
x:Vector3
The basis matrix's X vector (column 0).
Value: Equivalent to godot.Basis.column0
and array index [0]
.
y:Vector3
The basis matrix's Y vector (column 1).
Value: Equivalent to godot.Basis.column1
and array index [1]
.
z:Vector3
The basis matrix's Z vector (column 2).
Value: Equivalent to godot.Basis.column2
and array index [2]
.
Methods
determinant():Single
Returns the determinant of the basis matrix. If the basis is uniformly scaled, its determinant is the square of the scale.
A negative determinant means the basis has a negative scale. A zero determinant means the basis isn't invertible, and is usually considered invalid.
Returns:
The determinant of the basis matrix.
getAxis(axis:Int):Vector3
Deprecated, please use the array operator instead.
Parameters:
axis | Which column. |
---|
Returns:
One of Column0
, Column1
, or Column2
.
getColumn(index:Int):Vector3
Deprecated, please use the array operator instead.
Parameters:
index | Which column. |
---|
Returns:
One of Column0
, Column1
, or Column2
.
getEuler():Vector3
Returns the basis's rotation in the form of Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last). The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).
Consider using the godot.Basis.quat
method instead, which
returns a godot.Quat
quaternion instead of Euler angles.
Returns:
A godot.Vector3
representing the basis rotation in Euler angles.
getOrthogonalIndex():Int
This function considers a discretization of rotations into
24 points on unit sphere, lying along the vectors (x, y, z) with
each component being either -1, 0, or 1, and returns the index
of the point best representing the orientation of the object.
It is mainly used by the godot.GridMap
editor.
For further details, refer to the Godot source code.
Returns:
The orthogonal index.
getRow(index:Int):Vector3
Get rows by index. Rows are not very useful for user code, but are more efficient for some internal calculations.
@throws cs.system.IndexOutOfRangeException
Parameters:
index | Which row. |
---|
Returns:
One of Row0
, Row1
, or Row2
.
isEqualApprox(other:Basis):Bool
Returns true
if this basis and other
are approximately equal,
by running godot.Vector3.isEqualApprox
on each component.
Parameters:
other | The other basis to compare. |
---|
Returns:
Whether or not the bases are approximately equal.
orthonormalized():Basis
Returns the orthonormalized version of the basis matrix (useful to call occasionally to avoid rounding errors for orthogonal matrices). This performs a Gram-Schmidt orthonormalization on the basis of the matrix.
Returns:
An orthonormalized basis matrix.
quat():Quat
Returns the basis's rotation in the form of a quaternion.
See godot.Basis.getEuler
if you need Euler angles, but keep in
mind that quaternions should generally be preferred to Euler angles.
Returns:
A godot.Quat
representing the basis's rotation.
rotated(axis:Vector3, phi:Single):Basis
Introduce an additional rotation around the given axis
by phi
(in radians). 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 basis matrix.
rotationQuat():Quat
Returns the godot.Basis
's rotation in the form of a
godot.Basis.quat
. See godot.Basis.getEuler
if you
need Euler angles, but keep in mind quaternions should generally
be preferred to Euler angles.
Returns:
The basis rotation.
scaled(scale:Vector3):Basis
Introduce an additional scaling specified by the given 3D scaling factor.
Parameters:
scale | The scale to introduce. |
---|
Returns:
The scaled basis matrix.
setColumn(index:Int, value:Vector3):Void
Deprecated, please use the array operator instead.
Parameters:
index | Which column. |
---|---|
value | The vector to set the column to. |
setRow(index:Int, value:Vector3):Void
Sets rows by index. Rows are not very useful for user code, but are more efficient for some internal calculations.
@throws cs.system.IndexOutOfRangeException
Parameters:
index | Which row. |
---|---|
value | The vector to set the row to. |
slerp(target:Basis, weight:Single):Basis
Assuming that the matrix is a proper rotation matrix, slerp performs a spherical-linear interpolation with another rotation matrix.
Parameters:
target | The destination basis for interpolation. |
---|---|
weight | A value on the range of 0.0 to 1.0, representing the amount of interpolation. |
Returns:
The resulting basis matrix of the interpolation.
tdotx(with:Vector3):Single
Transposed dot product with the X axis of the matrix.
Parameters:
with | A vector to calculate the dot product with. |
---|
Returns:
The resulting dot product.
tdoty(with:Vector3):Single
Transposed dot product with the Y axis of the matrix.
Parameters:
with | A vector to calculate the dot product with. |
---|
Returns:
The resulting dot product.
tdotz(with:Vector3):Single
Transposed dot product with the Z axis of the matrix.
Parameters:
with | A vector to calculate the dot product with. |
---|
Returns:
The resulting dot product.
transposed():Basis
Returns the transposed version of the basis matrix.
Returns:
The transposed basis matrix.
xform(v:Vector3):Vector3
Returns a vector transformed (multiplied) by the basis 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 basis matrix.
Note: This results in a multiplication by the inverse of the basis matrix only if it represents a rotation-reflection.
Parameters:
v | A vector to inversely transform. |
---|
Returns:
The inversely transformed vector.
See also: