Click or drag to resize

Transform2D Structure

2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, or scaling. It consists of a three Vector2 values: x, y, and the origin. For more information, read this documentation article: https://docs.godotengine.org/en/3.3/tutorials/math/matrices_and_transforms.html

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
[SerializableAttribute]
public struct Transform2D : IEquatable<Transform2D>

The Transform2D type exposes the following members.

Constructors
  NameDescription
Public methodTransform2D(Single, Vector2)
Constructs a transformation matrix from a rotation value and origin vector.
Public methodTransform2D(Vector2, Vector2, Vector2)
Constructs a transformation matrix from 3 vectors (matrix columns).
Public methodTransform2D(Single, Single, Single, Single, Single, Single)
Constructs a transformation matrix from the given components. Arguments are named such that xy is equal to calling x.y
Top
Properties
  NameDescription
Public propertyStatic memberFlipX
The transform that will flip something along the X axis.
Public propertyStatic memberFlipY
The transform that will flip something along the Y axis.
Public propertyStatic memberIdentity
The identity transform, with no translation, rotation, or scaling applied. This is used as a replacement for `Transform2D()` in GDScript. Do not use `new Transform2D()` with no arguments in C#, because it sets all values to zero.
Public propertyItemInt32
Access whole columns in the form of Vector2. The third column is the origin vector.
Public propertyItemInt32, Int32
Access matrix elements in column-major order. The third column is the origin vector.
Public propertyRotation
The rotation of this transformation matrix.
Public propertyScale
The scale of this transformation matrix.
Top
Methods
  NameDescription
Public methodAffineInverse
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling, and translation.
Public methodBasisXform
Returns a vector transformed (multiplied) by the basis matrix. This method does not account for translation (the origin vector).
Public methodBasisXformInv
Returns a vector transformed (multiplied) by the inverse basis matrix. This method does not account for translation (the origin vector). Note: This results in a multiplication by the inverse of the basis matrix only if it represents a rotation-reflection.
Public methodEquals(Object) (Overrides ValueTypeEquals(Object).)
Public methodEquals(Transform2D)
Public methodGetHashCode (Overrides ValueTypeGetHashCode.)
Public methodGetType (Inherited from Object.)
Public methodInterpolateWith
Interpolates this transform to the other `transform` by `weight`.
Public methodInverse
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use AffineInverse for transforms with scaling).
Public methodIsEqualApprox
Returns true if this transform and `other` are approximately equal, by running IsEqualApprox(Vector2) on each component.
Public methodOrthonormalized
Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
Public methodRotated
Rotates the transform by `phi` (in radians), using matrix multiplication.
Public methodScaled
Scales the transform by the given scaling factor, using matrix multiplication.
Public methodToString (Overrides ValueTypeToString.)
Public methodToString(String)
Public methodTranslated
Translates the transform by the given `offset`, relative to the transform's basis vectors. Unlike Rotated(Single) and Scaled(Vector2), this does not use matrix multiplication.
Public methodXform
Returns a vector transformed (multiplied) by this transformation matrix.
Public methodXformInv
Returns a vector transformed (multiplied) by the inverse transformation matrix.
Top
Operators
Fields
  NameDescription
Public fieldorigin
The origin vector (column 2, the third column). Equivalent to array index `[2]`. The origin vector represents translation.
Public fieldx
The basis matrix's X vector (column 0). Equivalent to array index `[0]`.
Public fieldy
The basis matrix's Y vector (column 1). Equivalent to array index `[1]`.
Top
See Also