Transform3D

Struct Transform3D 

Source
#[repr(C)]
pub struct Transform3D { pub basis: Basis, pub origin: Vector3, }
Expand description

Affine 3D transform (3x4 matrix).

Used for 3D linear transformations. Uses a basis + origin representation.

Expressed as a 3x4 matrix, this transform consists of 3 basis (column) vectors a, b, c as well as an origin o:

[ a.x  b.x  c.x  o.x ]
[ a.y  b.y  c.y  o.y ]
[ a.z  b.z  c.z  o.z ]

§All matrix types

DimensionOrthogonal basisAffine transformProjective transform
2DTransform2D (2x3)
3DBasis (3x3)Transform3D (3x4)Projection (4x4)

§Transform operations

OperationTransform3DNotes
Applytransform * vSupports Aabb, Plane, Vector3.
Apply inversetransform.xform_inv(v)Supports Aabb, Plane, Vector3.
Apply, no translatetransform.basis * vSupports Vector3.
Apply inverse, no translatetransform.basis.xform_inv(v)Supports Vector3.

§Godot docs

Transform3D (stable)

Fields§

§basis: Basis

The basis is a matrix containing 3 vectors as its columns. They can be interpreted as the basis vectors of the transformed coordinate system.

§origin: Vector3

The new origin of the transformed coordinate system.

Implementations§

Source§

impl Transform3D

Source

pub const IDENTITY: Transform3D

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

Godot equivalent: Transform3D.IDENTITY

Source

pub const FLIP_X: Transform3D

Transform3D with mirroring applied perpendicular to the YZ plane.

Godot equivalent: Transform3D.FLIP_X

Source

pub const FLIP_Y: Transform3D

Transform3D with mirroring applied perpendicular to the XZ plane.

Godot equivalent: Transform3D.FLIP_Y

Source

pub const FLIP_Z: Transform3D

Transform3D with mirroring applied perpendicular to the XY plane.

Godot equivalent: Transform3D.FLIP_Z

Source

pub const fn new(basis: Basis, origin: Vector3) -> Transform3D

Create a new transform from a Basis and a Vector3.

Godot equivalent: Transform3D(Basis basis, Vector3 origin)

Source

pub const fn from_cols( a: Vector3, b: Vector3, c: Vector3, origin: Vector3, ) -> Transform3D

Create a new transform from 4 matrix-columns.

Godot equivalent: Transform3D(Vector3 x_axis, Vector3 y_axis, Vector3 z_axis, Vector3 origin), see Basis for why it’s changed

Source

pub fn from_projection(proj: &Projection) -> Transform3D

Constructs a Transform3D from a Projection by trimming the last row of the projection matrix.

Godot equivalent: Transform3D(Projection from)

Source

pub fn affine_inverse(&self) -> Transform3D

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

Source

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

Returns a transform interpolated between this transform and another by a given weight (on the range of 0.0 to 1.0).

Source

pub fn is_finite(&self) -> bool

Returns true if this transform is finite by calling is_finite on the basis and origin.

Source

pub fn looking_at( &self, target: Vector3, up: Vector3, use_model_front: bool, ) -> Transform3D

Source

pub fn orthonormalized(&self) -> Transform3D

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

Godot equivalent: Transform3D.orthonormalized()

Source

pub fn rotated(&self, axis: Vector3, angle: f32) -> Transform3D

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()

Source

pub fn rotated_local(&self, axis: Vector3, angle: f32) -> Transform3D

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()

Source

pub fn scaled(&self, scale: Vector3) -> Transform3D

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()

Source

pub fn scaled_local(&self, scale: Vector3) -> Transform3D

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()

Source

pub fn translated(&self, offset: Vector3) -> Transform3D

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()

Source

pub fn translated_local(&self, offset: Vector3) -> Transform3D

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()

Trait Implementations§

Source§

impl ApproxEq for Transform3D

Source§

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

Returns if the two transforms are approximately equal, by comparing basis and origin separately.

Source§

impl Clone for Transform3D

Source§

fn clone(&self) -> Transform3D

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Transform3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Transform3D

Source§

fn default() -> Transform3D

Returns the “default value” for a type. Read more
Source§

impl Display for Transform3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value with the given formatter. Read more

The output is similar to Godot’s, but calls the columns a/b/c instead of X/Y/Z. See Basis for why.

Source§

impl DynamicSend for Transform3D

Source§

impl Export for Transform3D

Source§

fn export_hint() -> PropertyHintInfo

The export info to use for an exported field of this type, if no other export info is specified.
Source§

impl From<Basis> for Transform3D

Source§

fn from(basis: Basis) -> Transform3D

Create a new transform with origin (0,0,0) from this basis.

Source§

impl From<Transform3D> for Projection

Source§

fn from(trans: Transform3D) -> Projection

Converts to this type from the input type.
Source§

impl FromGodot for Transform3D

Source§

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

Converts the Godot representation to this type, returning Err on failure.
Source§

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

⚠️ Converts the Godot representation to this type. Read more
Source§

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

Performs the conversion from a Variant, returning Err on failure.
Source§

fn from_variant(variant: &Variant) -> Self

⚠️ Performs the conversion from a Variant. Read more
Source§

impl GodotConvert for Transform3D

Source§

type Via = Transform3D

The type through which Self is represented in Godot.
Source§

impl IntoDynamicSend for Transform3D

Source§

impl Mul<Aabb> for Transform3D

Source§

fn mul(self, rhs: Aabb) -> <Transform3D as Mul<Aabb>>::Output

Transforms each coordinate in rhs.position and rhs.end() individually by this transform, then creates an Aabb containing all of them.

Source§

type Output = Aabb

The resulting type after applying the * operator.
Source§

impl Mul<Plane> for Transform3D

Source§

type Output = Plane

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Plane) -> <Transform3D as Mul<Plane>>::Output

Performs the * operation. Read more
Source§

impl Mul<Vector3> for Transform3D

Source§

type Output = Vector3

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector3) -> <Transform3D as Mul<Vector3>>::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for Transform3D

Source§

type Output = Transform3D

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> <Transform3D as Mul<f32>>::Output

Performs the * operation. Read more
Source§

impl Mul for Transform3D

Source§

type Output = Transform3D

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl PartialEq for Transform3D

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToGodot for Transform3D

Source§

type Pass = ByValue

Whether arguments of this type are passed by value or by reference. Read more
Source§

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

Converts this type to Godot representation, optimizing for zero-copy when possible. Read more
Source§

fn to_godot_owned(&self) -> Self::Via
where Self::Via: Clone,

Converts this type to owned Godot representation. Read more
Source§

fn to_variant(&self) -> Variant

Converts this type to a Variant.
Source§

impl Var for Transform3D

Source§

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

Source§

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

Source§

fn var_hint() -> PropertyHintInfo

Specific property hints, only override if they deviate from GodotType::property_info, e.g. for enums/newtypes.
Source§

impl XformInv<Aabb> for Transform3D

Source§

fn xform_inv(&self, rhs: Aabb) -> Aabb

Inversely transforms each vertex in given Aabb individually by this transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not), and then creates an Aabb encompassing all of them.

For transforming by inverse of an affine transformation (e.g. with scaling) transform.affine_inverse() * aabb can be used instead. See Transform3D::affine_inverse().

Godot equivalent: aabb * transform

Source§

impl XformInv<Plane> for Transform3D

Source§

fn xform_inv(&self, rhs: Plane) -> Plane

Inversely transforms (multiplies) the Plane by the given Transform3D transformation matrix.

transform.xform_inv(plane) is equivalent to transform.affine_inverse() * plane. See Transform3D::affine_inverse().

Godot equivalent: plane * transform

Source§

impl XformInv<Vector3> for Transform3D

Source§

fn xform_inv(&self, rhs: Vector3) -> Vector3

Inversely transforms given Vector3 by this transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).

For transforming by inverse of an affine transformation (e.g. with scaling) transform.affine_inverse() * vector can be used instead. See Transform3D::affine_inverse().

Godot equivalent: aabb * transform

Source§

impl ArrayElement for Transform3D

Source§

impl BuiltinExport for Transform3D

Source§

impl Copy for Transform3D

Source§

impl GodotType for Transform3D

Source§

impl StructuralPartialEq for Transform3D

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsArg<T> for T
where T: ToGodot<Pass = ByValue>,

Source§

fn into_arg<'arg>(self) -> CowArg<'arg, T>
where T: 'arg,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.