Struct Transform3D
#[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
| Dimension | Orthogonal basis | Affine transform | Projective transform |
|---|---|---|---|
| 2D | Transform2D (2x3) | ||
| 3D | Basis (3x3) | Transform3D (3x4) | Projection (4x4) |
§Transform operations
| Operation | Transform3D | Notes |
|---|---|---|
| Apply | transform * v | Supports Aabb, Plane, Vector3. |
| Apply inverse | transform.xform_inv(v) | Supports Aabb, Plane, Vector3. |
| Apply, no translate | transform.basis * v | Supports Vector3. |
| Apply inverse, no translate | transform.basis.xform_inv(v) | Supports Vector3. |
§Godot docs
Fields§
§basis: BasisThe basis is a matrix containing 3 vectors as its columns. They can be interpreted as the basis vectors of the transformed coordinate system.
origin: Vector3The new origin of the transformed coordinate system.
Implementations§
§impl Transform3D
impl Transform3D
pub const IDENTITY: Transform3D
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
pub const FLIP_X: Transform3D
pub const FLIP_X: Transform3D
Transform3D with mirroring applied perpendicular to the YZ plane.
Godot equivalent: Transform3D.FLIP_X
pub const FLIP_Y: Transform3D
pub const FLIP_Y: Transform3D
Transform3D with mirroring applied perpendicular to the XZ plane.
Godot equivalent: Transform3D.FLIP_Y
pub const FLIP_Z: Transform3D
pub const FLIP_Z: Transform3D
Transform3D with mirroring applied perpendicular to the XY plane.
Godot equivalent: Transform3D.FLIP_Z
pub const fn new(basis: Basis, origin: Vector3) -> Transform3D
pub const fn new(basis: Basis, origin: Vector3) -> Transform3D
pub const fn from_cols(
a: Vector3,
b: Vector3,
c: Vector3,
origin: Vector3,
) -> Transform3D
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
pub fn from_projection(proj: &Projection) -> Transform3D
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)
pub fn affine_inverse(&self) -> Transform3D
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.
pub fn interpolate_with(&self, other: &Transform3D, weight: f32) -> Transform3D
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).
pub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
Returns true if this transform is finite by calling is_finite on the
basis and origin.
pub fn orthonormalized(&self) -> Transform3D
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()
pub fn rotated(&self, axis: Vector3, angle: f32) -> Transform3D
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()
pub fn rotated_local(&self, axis: Vector3, angle: f32) -> Transform3D
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()
pub fn scaled(&self, scale: Vector3) -> Transform3D
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()
pub fn scaled_local(&self, scale: Vector3) -> Transform3D
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()
pub fn translated(&self, offset: Vector3) -> Transform3D
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()
pub fn translated_local(&self, offset: Vector3) -> Transform3D
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()
§impl Transform3D
impl Transform3D
pub fn looking_at(&self, target: Vector3) -> Transform3D
pub fn looking_at(&self, target: Vector3) -> Transform3D
To set the default parameters, use Self::looking_at_ex and its builder methods. See the book for detailed usage instructions.
pub fn looking_at_ex<'ex>(&'ex self, target: Vector3) -> ExLookingAt<'ex>
Trait Implementations§
§impl ApproxEq for Transform3D
impl ApproxEq for Transform3D
§fn approx_eq(&self, other: &Transform3D) -> bool
fn approx_eq(&self, other: &Transform3D) -> bool
Returns if the two transforms are approximately equal, by comparing basis and origin separately.
§impl Clone for Transform3D
impl Clone for Transform3D
§fn clone(&self) -> Transform3D
fn clone(&self) -> Transform3D
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Transform3D
impl Debug for Transform3D
§impl Default for Transform3D
impl Default for Transform3D
§fn default() -> Transform3D
fn default() -> Transform3D
§impl Display for Transform3D
impl Display for Transform3D
§impl DynamicSend for Transform3D
impl DynamicSend for Transform3D
type Inner = Transform3D
fn extract_if_safe(self) -> Option<<Transform3D as DynamicSend>::Inner>
§impl Export for Transform3D
impl Export for Transform3D
§fn export_hint() -> PropertyHintInfo
fn export_hint() -> PropertyHintInfo
§impl From<Basis> for Transform3D
impl From<Basis> for Transform3D
§fn from(basis: Basis) -> Transform3D
fn from(basis: Basis) -> Transform3D
Create a new transform with origin (0,0,0) from this basis.
§impl From<Transform3D> for Projection
impl From<Transform3D> for Projection
§fn from(trans: Transform3D) -> Projection
fn from(trans: Transform3D) -> Projection
§impl FromGodot for Transform3D
impl FromGodot for Transform3D
§fn try_from_godot(
via: <Transform3D as GodotConvert>::Via,
) -> Result<Transform3D, ConvertError>
fn try_from_godot( via: <Transform3D as GodotConvert>::Via, ) -> Result<Transform3D, 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 Transform3D
impl GodotConvert for Transform3D
§type Via = Transform3D
type Via = Transform3D
Self is represented in Godot.§impl GodotImmutable for Transform3D
impl GodotImmutable for Transform3D
fn into_runtime_immutable(self) -> Self
§impl IntoDynamicSend for Transform3D
impl IntoDynamicSend for Transform3D
type Target = Transform3D
fn into_dynamic_send(self) -> <Transform3D as IntoDynamicSend>::Target
§impl Mul<Aabb> for Transform3D
impl Mul<Aabb> for Transform3D
§impl Mul<Plane> for Transform3D
impl Mul<Plane> for Transform3D
§impl Mul<Vector3> for Transform3D
impl Mul<Vector3> for Transform3D
§impl Mul<f32> for Transform3D
impl Mul<f32> for Transform3D
§impl Mul for Transform3D
impl Mul for Transform3D
§type Output = Transform3D
type Output = Transform3D
* operator.§fn mul(self, rhs: Transform3D) -> <Transform3D as Mul>::Output
fn mul(self, rhs: Transform3D) -> <Transform3D as Mul>::Output
* operation. Read more§impl PartialEq for Transform3D
impl PartialEq for Transform3D
§impl ToGodot for Transform3D
impl ToGodot for Transform3D
§fn to_godot(&self) -> <Transform3D as GodotConvert>::Via
fn to_godot(&self) -> <Transform3D as GodotConvert>::Via
§fn to_godot_owned(&self) -> Self::Via
fn to_godot_owned(&self) -> Self::Via
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
§impl Var for Transform3D
impl Var for Transform3D
fn get_property(&self) -> <Transform3D as GodotConvert>::Via
fn set_property(&mut self, value: <Transform3D as GodotConvert>::Via)
§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info, e.g. for enums/newtypes.§impl XformInv<Aabb> for Transform3D
impl XformInv<Aabb> for Transform3D
§fn xform_inv(&self, rhs: Aabb) -> Aabb
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
§impl XformInv<Plane> for Transform3D
impl XformInv<Plane> for Transform3D
§fn xform_inv(&self, rhs: Plane) -> Plane
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
§impl XformInv<Vector3> for Transform3D
impl XformInv<Vector3> for Transform3D
§fn xform_inv(&self, rhs: Vector3) -> Vector3
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
impl ArrayElement for Transform3D
impl BuiltinExport for Transform3D
impl Copy for Transform3D
impl GodotType for Transform3D
impl StructuralPartialEq for Transform3D
Auto Trait Implementations§
impl Freeze for Transform3D
impl RefUnwindSafe for Transform3D
impl Send for Transform3D
impl Sync for Transform3D
impl Unpin for Transform3D
impl UnwindSafe for Transform3D
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)