# Struct godot::builtin::Transform2D

```
#[repr(C)]pub struct Transform2D {
pub a: Vector2,
pub b: Vector2,
pub origin: Vector2,
}
```

## Expand description

Affine 2D transform (2x3 matrix).

Represents transformations such as translation, rotation, or scaling.

Expressed as a 2x3 matrix, this transform consists of a two column vectors
`a`

and `b`

representing the basis of the transform, as well as the origin:

```
[ a.x b.x origin.x ]
[ a.y b.y origin.y ]
```

## Fields§

§`a: Vector2`

The first basis vector.

*Godot equivalent: Transform2D.x*, see

`Basis`

for why it’s changed`b: Vector2`

The second basis vector.

*Godot equivalent: Transform2D.y*, see

`Basis`

for why it’s changed`origin: Vector2`

The origin of the transform. The coordinate space defined by this transform starts at this point.

*Godot equivalent: Transform2D.origin*

## Implementations§

§### impl Transform2D

### impl Transform2D

#### pub const IDENTITY: Transform2D = _

#### pub const IDENTITY: Transform2D = _

The identity transform, with no translation, rotation or scaling
applied. When applied to other data structures, `IDENTITY`

performs no
transformation.

*Godot equivalent: Transform2D.IDENTITY*

#### pub const FLIP_X: Transform2D = _

#### pub const FLIP_X: Transform2D = _

The `Transform2D`

that will flip something along its X axis.

*Godot equivalent: Transform2D.FLIP_X*

#### pub const FLIP_Y: Transform2D = _

#### pub const FLIP_Y: Transform2D = _

The `Transform2D`

that will flip something along its Y axis.

*Godot equivalent: Transform2D.FLIP_Y*

#### pub const fn from_cols(a: Vector2, b: Vector2, origin: Vector2) -> Transform2D

#### pub const fn from_cols(a: Vector2, b: Vector2, origin: Vector2) -> Transform2D

Create a new `Transform2D`

with the given column vectors.

*Godot equivalent: Transform2D(Vector2 x_axis, Vector2 y_axis, Vector2 origin)*, see

`Basis`

for why it’s
changed#### pub fn from_angle(angle: f32) -> Transform2D

#### pub fn from_angle(angle: f32) -> Transform2D

Create a new `Transform2D`

which will rotate by the given angle.

#### pub fn from_angle_origin(angle: f32, origin: Vector2) -> Transform2D

#### pub fn from_angle_origin(angle: f32, origin: Vector2) -> Transform2D

Create a new `Transform2D`

which will rotate by `angle`

and translate
by `origin`

.

*Godot equivalent: Transform2D(float rotation, Vector2 position)*

#### pub fn from_angle_scale_skew_origin(
angle: f32,
scale: Vector2,
skew: f32,
origin: Vector2,
) -> Transform2D

#### pub fn from_angle_scale_skew_origin( angle: f32, scale: Vector2, skew: f32, origin: Vector2, ) -> Transform2D

Create a new `Transform2D`

which will rotate by `angle`

, scale by
`scale`

, skew by `skew`

and translate by `origin`

.

*Godot equivalent: Transform2D(float rotation, Vector2 scale, float skew, Vector2 position)*

#### pub fn affine_inverse(&self) -> Transform2D

#### pub fn affine_inverse(&self) -> Transform2D

Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation.

*Godot equivalent: Transform2D.affine_inverse()*

#### pub fn determinant(&self) -> f32

#### pub fn determinant(&self) -> f32

Returns the determinant of the basis matrix.

If the basis is uniformly scaled, then its determinant equals the square of the scale factor.

A negative determinant means the basis was flipped, so one part of the scale is negative. A zero determinant means the basis isn’t invertible, and is usually considered invalid.

*Godot equivalent: Transform2D.determinant()*

#### pub fn rotation(&self) -> f32

#### pub fn rotation(&self) -> f32

Returns the transform’s rotation (in radians).

*Godot equivalent: Transform2D.get_rotation()*

#### pub fn scale(&self) -> Vector2

#### pub fn scale(&self) -> Vector2

Returns the transform’s scale.

*Godot equivalent: Transform2D.get_scale()*

#### pub fn skew(&self) -> f32

#### pub fn skew(&self) -> f32

Returns the transform’s skew (in radians).

*Godot equivalent: Transform2D.get_skew()*

#### pub fn interpolate_with(&self, other: &Transform2D, weight: f32) -> Transform2D

#### pub fn interpolate_with(&self, other: &Transform2D, weight: f32) -> Transform2D

Returns a transform interpolated between this transform and another by
a given `weight`

(on the range of 0.0 to 1.0).

*Godot equivalent: Transform2D.interpolate_with()*

#### pub fn is_finite(&self) -> bool

#### pub fn is_finite(&self) -> bool

Returns `true`

if this transform is finite, by calling
`Vector2::is_finite()`

on each component.

*Godot equivalent: Transform2D.is_finite()*

#### pub fn orthonormalized(&self) -> Transform2D

#### pub fn orthonormalized(&self) -> Transform2D

Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).

*Godot equivalent: Transform2D.orthonormalized()*

#### pub fn rotated(&self, angle: f32) -> Transform2D

#### pub fn rotated(&self, angle: f32) -> Transform2D

Returns a copy of the transform rotated by the given `angle`

(in radians).
This method is an optimized version of multiplying the given transform `X`

with a corresponding rotation transform `R`

from the left, i.e., `R * X`

.
This can be seen as transforming with respect to the global/parent frame.

*Godot equivalent: Transform2D.rotated()*

#### pub fn rotated_local(&self, angle: f32) -> Transform2D

#### pub fn rotated_local(&self, angle: f32) -> Transform2D

Returns a copy of the transform rotated by the given `angle`

(in radians).
This method is an optimized version of multiplying the given transform `X`

with a corresponding rotation transform `R`

from the right, i.e., `X * R`

.
This can be seen as transforming with respect to the local frame.

*Godot equivalent: Transform2D.rotated_local()*

#### pub fn scaled(&self, scale: Vector2) -> Transform2D

#### pub fn scaled(&self, scale: Vector2) -> Transform2D

Returns a copy of the transform scaled by the given scale factor.
This method is an optimized version of multiplying the given transform `X`

with a corresponding scaling transform `S`

from the left, i.e., `S * X`

.
This can be seen as transforming with respect to the global/parent frame.

*Godot equivalent: Transform2D.scaled()*

#### pub fn scaled_local(&self, scale: Vector2) -> Transform2D

#### pub fn scaled_local(&self, scale: Vector2) -> Transform2D

Returns a copy of the transform scaled by the given scale factor.
This method is an optimized version of multiplying the given transform `X`

with a corresponding scaling transform `S`

from the right, i.e., `X * S`

.
This can be seen as transforming with respect to the local frame.

*Godot equivalent: Transform2D.scaled_local()*

#### pub fn translated(&self, offset: Vector2) -> Transform2D

#### pub fn translated(&self, offset: Vector2) -> Transform2D

Returns a copy of the transform translated by the given offset.
This method is an optimized version of multiplying the given transform `X`

with a corresponding translation transform `T`

from the left, i.e., `T * X`

.
This can be seen as transforming with respect to the global/parent frame.

*Godot equivalent: Transform2D.translated()*

#### pub fn translated_local(&self, offset: Vector2) -> Transform2D

#### pub fn translated_local(&self, offset: Vector2) -> Transform2D

Returns a copy of the transform translated by the given offset.
This method is an optimized version of multiplying the given transform `X`

with a corresponding translation transform `T`

from the right, i.e., `X * T`

.
This can be seen as transforming with respect to the local frame.

*Godot equivalent: Transform2D.translated()*

#### pub fn basis_xform(&self, v: Vector2) -> Vector2

#### pub fn basis_xform(&self, v: Vector2) -> Vector2

Returns a vector transformed (multiplied) by the basis matrix. This method does not account for translation (the origin vector).

*Godot equivalent: Transform2D.basis_xform()*

#### pub fn basis_xform_inv(&self, v: Vector2) -> Vector2

#### pub fn basis_xform_inv(&self, v: Vector2) -> Vector2

Returns a vector transformed (multiplied) by the inverse basis matrix. This method does not account for translation (the origin vector).

*Godot equivalent: Transform2D.basis_xform_inv()*

## Trait Implementations§

§### impl ApproxEq for Transform2D

### impl ApproxEq for Transform2D

§#### fn approx_eq(&self, other: &Transform2D) -> bool

#### fn approx_eq(&self, other: &Transform2D) -> bool

Returns if the two transforms are approximately equal, by comparing each component separately.

§### impl Clone for Transform2D

### impl Clone for Transform2D

§#### fn clone(&self) -> Transform2D

#### fn clone(&self) -> Transform2D

1.0.0 · source§#### fn clone_from(&mut self, source: &Self)

#### fn clone_from(&mut self, source: &Self)

`source`

. Read more§### impl Debug for Transform2D

### impl Debug for Transform2D

§### impl Default for Transform2D

### impl Default for Transform2D

§#### fn default() -> Transform2D

#### fn default() -> Transform2D

§### impl Display for Transform2D

### impl Display for Transform2D

§### impl Export for Transform2D

### impl Export for Transform2D

§#### fn default_export_info() -> PropertyHintInfo

#### fn default_export_info() -> PropertyHintInfo

§### impl FromGodot for Transform2D

### impl FromGodot for Transform2D

§#### fn try_from_godot(
via: <Transform2D as GodotConvert>::Via,
) -> Result<Transform2D, ConvertError>

#### fn try_from_godot( via: <Transform2D as GodotConvert>::Via, ) -> Result<Transform2D, ConvertError>

`Err`

on failure.§#### fn from_godot(via: Self::Via) -> Self

#### fn from_godot(via: Self::Via) -> Self

§#### fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>

#### fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>

`Variant`

, returning `Err`

on failure.§#### fn from_variant(variant: &Variant) -> Self

#### fn from_variant(variant: &Variant) -> Self

§### impl GodotConvert for Transform2D

### impl GodotConvert for Transform2D

§#### type Via = Transform2D

#### type Via = Transform2D

`Self`

is represented in Godot.§### impl Mul<Rect2> for Transform2D

### impl Mul<Rect2> for Transform2D

§### impl Mul<Vector2> for Transform2D

### impl Mul<Vector2> for Transform2D

§### impl Mul<f32> for Transform2D

### impl Mul<f32> for Transform2D

§### impl Mul for Transform2D

### impl Mul for Transform2D

§#### type Output = Transform2D

#### type Output = Transform2D

`*`

operator.§#### fn mul(self, rhs: Transform2D) -> <Transform2D as Mul>::Output

#### fn mul(self, rhs: Transform2D) -> <Transform2D as Mul>::Output

`*`

operation. Read more§### impl PartialEq for Transform2D

### impl PartialEq for Transform2D

§#### fn eq(&self, other: &Transform2D) -> bool

#### fn eq(&self, other: &Transform2D) -> bool

`self`

and `other`

values to be equal, and is used
by `==`

.§### impl ToGodot for Transform2D

### impl ToGodot for Transform2D

§#### fn to_godot(&self) -> <Transform2D as GodotConvert>::Via

#### fn to_godot(&self) -> <Transform2D as GodotConvert>::Via

§#### fn into_godot(self) -> <Transform2D as GodotConvert>::Via

#### fn into_godot(self) -> <Transform2D as GodotConvert>::Via

§#### fn to_variant(&self) -> Variant

#### fn to_variant(&self) -> Variant

§### impl TypeStringHint for Transform2D

### impl TypeStringHint for Transform2D

§#### fn type_string() -> String

#### fn type_string() -> String

§### impl Var for Transform2D

### impl Var for Transform2D

#### fn get_property(&self) -> <Transform2D as GodotConvert>::Via

#### fn set_property(&mut self, value: <Transform2D as GodotConvert>::Via)

#### fn property_hint() -> PropertyHintInfo

### impl ArrayElement for Transform2D

### impl Copy for Transform2D

### impl GodotType for Transform2D

### impl StructuralPartialEq for Transform2D

## Auto Trait Implementations§

### impl Freeze for Transform2D

### impl RefUnwindSafe for Transform2D

### impl Send for Transform2D

### impl Sync for Transform2D

### impl Unpin for Transform2D

### impl UnwindSafe for Transform2D

## Blanket Implementations§

source§### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

source§#### fn borrow_mut(&mut self) -> &mut T

#### fn borrow_mut(&mut self) -> &mut T

source§### impl<T> CloneToUninit for Twhere
T: Copy,

### impl<T> CloneToUninit for Twhere
T: Copy,

source§#### unsafe fn clone_to_uninit(&self, dst: *mut T)

#### unsafe fn clone_to_uninit(&self, dst: *mut T)

`clone_to_uninit`

)source§### impl<T> CloneToUninit for Twhere
T: Clone,

### impl<T> CloneToUninit for Twhere
T: Clone,

source§#### default unsafe fn clone_to_uninit(&self, dst: *mut T)

#### default unsafe fn clone_to_uninit(&self, dst: *mut T)

`clone_to_uninit`

)