reckfellENGINE

Transform3D

Basis and translation for local/world conversion.

On this page
struct Transform3DReckfellSharpInherits ValueType

transform × point includes Basis and Origin; Basis × direction adds no translation. parent × child applies child first. For an Entity3D with an Entity3D parent and TopLevel = false, the world transform normally equals parent.GlobalTransform × Transform. TopLevel disables inheritance. Recalculation with SetDisableScale(true) orthonormalizes the world Basis; the flag alone does not update an already cached transform.

Inverse and point × transform require an orthonormal basis; scale needs AffineInverse with nonzero determinant. Rotated also rotates Origin around the external origin; RotatedLocal preserves Origin. Transform interpolation is not collision-aware physics movement.

Practical guide.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors4

Transform3D4 overloads
# Transform3D · 1/4
C#
public Transform3D(Basis basis, Vector3 origin);

Constructs a Transform3D from four Vector3 values (also called matrix columns). The first three arguments are the Transform3D.Basis's axes (Basis.X, Basis.Y, and Basis.Z).

Parameters
NameTypeDefault
basisBasis—
originVector3—
basis

The Basis to create the basis from.

origin

The origin vector, or column index 3.

# Transform3D · 2/4
C#
public Transform3D(Projection projection);

Constructs a Transform3D from four Vector3 values (also called matrix columns). The first three arguments are the Transform3D.Basis's axes (Basis.X, Basis.Y, and Basis.Z).

Parameters
NameTypeDefault
projectionProjection—
projection

The Projection to create the transform from.

# Transform3D · 3/4
C#
public Transform3D(Vector3 column0, Vector3 column1, Vector3 column2, Vector3 origin);

Constructs a Transform3D from four Vector3 values (also called matrix columns). The first three arguments are the Transform3D.Basis's axes (Basis.X, Basis.Y, and Basis.Z).

Parameters
NameTypeDefault
column0Vector3—
column1Vector3—
column2Vector3—
originVector3—
column0

The X vector, or column index 0.

column1

The Y vector, or column index 1.

column2

The Z vector, or column index 2.

origin

The origin vector, or column index 3.

# Transform3D · 4/4
C#
public Transform3D(float xx, float yx, float zx, float xy, float yy, float zy, float xz, float yz, float zz, float ox, float oy, float oz);

Constructs a Transform3D from four Vector3 values (also called matrix columns). The first three arguments are the Transform3D.Basis's axes (Basis.X, Basis.Y, and Basis.Z).

Parameters
NameTypeDefault
xxfloat—
yxfloat—
zxfloat—
xyfloat—
yyfloat—
zyfloat—
xzfloat—
yzfloat—
zzfloat—
oxfloat—
oyfloat—
ozfloat—
xx

The X component of the X column vector, accessed via t.Basis.X.X or [0][0].

yx

The X component of the Y column vector, accessed via t.Basis.Y.X or [1][0].

zx

The X component of the Z column vector, accessed via t.Basis.Z.X or [2][0].

xy

The Y component of the X column vector, accessed via t.Basis.X.Y or [0][1].

yy

The Y component of the Y column vector, accessed via t.Basis.Y.Y or [1][1].

zy

The Y component of the Z column vector, accessed via t.Basis.Y.Y or [2][1].

xz

The Z component of the X column vector, accessed via t.Basis.X.Y or [0][2].

yz

The Z component of the Y column vector, accessed via t.Basis.Y.Y or [1][2].

zz

The Z component of the Z column vector, accessed via t.Basis.Y.Y or [2][2].

ox

The X component of the origin vector, accessed via t.Origin.X or [2][0].

oy

The Y component of the origin vector, accessed via t.Origin.Y or [2][1].

oz

The Z component of the origin vector, accessed via t.Origin.Z or [2][2].

Properties6

FlipXProperty
# FlipX
C#
public static Transform3D FlipX { get; }

Transform3D with mirroring applied perpendicular to the YZ plane. Its Transform3D.Basis is equal to Basis.FlipX.

FlipYProperty
# FlipY
C#
public static Transform3D FlipY { get; }

Transform3D with mirroring applied perpendicular to the XZ plane. Its Transform3D.Basis is equal to Basis.FlipY.

FlipZProperty
# FlipZ
C#
public static Transform3D FlipZ { get; }

Transform3D with mirroring applied perpendicular to the XY plane. Its Transform3D.Basis is equal to Basis.FlipZ.

IdentityProperty
# Identity
C#
public static Transform3D Identity { get; }

The identity Transform3D. This is a transform with no translation, no rotation, and a scale of Vector3.One. Its Transform3D.Basis is equal to Basis.Identity. This also means that:

If a Vector3, an Aabb, a Plane, a Vector3[], or another Transform3D is transformed (multiplied) by this constant, no transformation occurs. Note: In C#, this constant is equivalent to creating a [constructor Transform3D] without any arguments. It can be used to make your code clearer, and for consistency with C#.

Item2 overloads
# Item · 1/2
C#
public Vector3 this[int column] { get; set; }

Access whole columns in the form of Vector3. The fourth column is the Transform3D.Origin vector.

# Item · 2/2
C#
public float this[int column, int row] { get; set; }

Access matrix elements in column-major order. The fourth column is the Transform3D.Origin vector.

Methods30

AffineInverseTransform3D
# AffineInverse
C#
public Transform3D AffineInverse();

Inverts Basis and translation, including scale. An exactly zero Basis determinant throws InvalidOperationException. Transform a surface normal with inverse-transposed Basis, without translation.

Returns Transform3D

The inverse value. An exactly zero determinant throws InvalidOperationException instead of returning a result.

Equals2 overloads
# Equals · 1/2
C#
public bool Equals(Transform3D other);

Returns true if the transforms are exactly equal. Note: Due to floating-point precision errors, consider using Transform3D.IsEqualApprox instead, which is more reliable.

Parameters
NameTypeDefault
otherTransform3D—
other

The other transform to compare.

Returns bool

Whether or not the matrices are exactly equal.

# Equals · 2/2
C#
public override bool Equals(object? obj);

Returns true if the transform is exactly equal to the given object (obj). Note: Due to floating-point precision errors, consider using Transform3D.IsEqualApprox instead, which is more reliable.

Parameters
NameTypeDefault
objobject—
obj

The object to compare with.

Returns bool

Whether or not the transform and the object are exactly equal.

GetHashCodeint
# GetHashCode
C#
public override int GetHashCode();

Serves as the hash function for Transform3D.

Returns int

A hash code for this transform.

InterpolateWithTransform3D
# InterpolateWith
C#
public Transform3D InterpolateWith(Transform3D transform, float weight);

Returns the result of the linear interpolation between this transform and xform by the given weight. The weight should be between 0.0 and 1.0 (inclusive). Values outside this range are allowed and can be used to perform extrapolation instead.

Parameters
NameTypeDefault
transformTransform3D—
weightfloat—
transform

The other transform.

weight

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns Transform3D

The interpolated transform.

InverseTransform3D
# Inverse
C#
public Transform3D Inverse();

Uses a transposed Basis and assumes orthonormality. Does not replace AffineInverse under nonuniform scale.

Returns Transform3D

The inverse matrix.

IsEqualApproxbool
# IsEqualApprox
C#
public bool IsEqualApprox(Transform3D other);

Returns true if this transform and xform are approximately equal, by running @GlobalScope.is_equal_approx on each component.

Parameters
NameTypeDefault
otherTransform3D—
other

The other transform to compare.

Returns bool

Whether or not the matrices are approximately equal.

IsFinitebool
# IsFinite
C#
public bool IsFinite();

Returns true if this transform is finite, by calling @GlobalScope.is_finite on each component.

Returns bool

Whether this vector is finite or not.

LookingAt2 overloads
# LookingAt · 1/2
C#
public Transform3D LookingAt(Vector3 target, Vector3 up);

Returns a copy of this transform rotated so that the forward axis (-Z) points towards the target position. The up axis (+Y) points as close to the up vector as possible while staying perpendicular to the forward axis. The resulting transform is orthonormalized. The existing rotation, scale, and skew information from the original transform is discarded. The target and up vectors cannot be zero, cannot be parallel to each other, and are defined in global/parent space. If use_model_front is true, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the target position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right).

Parameters
NameTypeDefault
targetVector3—
upVector3—
Returns Transform3D
# LookingAt · 2/2
C#
public Transform3D LookingAt(Vector3 target, Vector3? up = default, bool useModelFront = false);

Returns a copy of this transform rotated so that the forward axis (-Z) points towards the target position. The up axis (+Y) points as close to the up vector as possible while staying perpendicular to the forward axis. The resulting transform is orthonormalized. The existing rotation, scale, and skew information from the original transform is discarded. The target and up vectors cannot be zero, cannot be parallel to each other, and are defined in global/parent space. If use_model_front is true, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the target position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right).

Parameters
NameTypeDefault
targetVector3—
upVector3?default
useModelFrontboolfalse
target

The object to look at.

up

The relative up direction.

useModelFront

If true, then the model is oriented in reverse, towards the model front axis (+Z, Vector3.ModelFront), which is more useful for orienting 3D models.

Returns Transform3D

The resulting transform.

OrthonormalizedTransform3D
# Orthonormalized
C#
public Transform3D Orthonormalized();

Returns a copy of this transform with its Transform3D.Basis orthonormalized. An orthonormal basis is both orthogonal (the axes are perpendicular to each other) and normalized (the axes have a length of 1.0), which also means it can only represent a rotation. See also Basis.Orthonormalized.

Returns Transform3D

The orthonormalized transform.

RotatedTransform3D
# Rotated
C#
public Transform3D Rotated(Vector3 axis, float angle);

Rotates in external space, including Origin around the external origin. axis must have unit length; angle is in radians. Returns a copy without modifying the original value.

Parameters
NameTypeDefault
axisVector3—
anglefloat—
axis

Unit axis in external space.

angle

Angle in radians; convert degrees with Mathf.DegToRad.

Returns Transform3D

A copy with a new Basis and rotated Origin.

RotatedLocalTransform3D
# RotatedLocal
C#
public Transform3D RotatedLocal(Vector3 axis, float angle);

Rotates in the local basis and preserves Origin. axis must have unit length; angle is in radians. Returns a copy without modifying the original value.

Parameters
NameTypeDefault
axisVector3—
anglefloat—
axis

Unit axis in local space.

angle

Angle in radians; convert degrees with Mathf.DegToRad.

Returns Transform3D

A copy with a new Basis and unchanged Origin.

ScaledTransform3D
# Scaled
C#
public Transform3D Scaled(Vector3 scale);

Returns a copy of this 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.

Parameters
NameTypeDefault
scaleVector3—
scale

The scale to introduce.

Returns Transform3D

The scaled transformation matrix.

ScaledLocalTransform3D
# ScaledLocal
C#
public Transform3D ScaledLocal(Vector3 scale);

Returns a copy of this 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.

Parameters
NameTypeDefault
scaleVector3—
scale

The scale to introduce.

Returns Transform3D

The scaled transformation matrix.

ToString2 overloads
# ToString · 1/2
C#
public override string ToString();

Converts this Transform3D to a string.

Returns string

A string representation of this transform.

# ToString · 2/2
C#
public string ToString(string? format);

Converts this Transform3D to a string with the given format.

Parameters
NameTypeDefault
formatstring—
Returns string

A string representation of this transform.

TranslatedTransform3D
# Translated
C#
public Transform3D Translated(Vector3 offset);

Returns a copy of this 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.

Parameters
NameTypeDefault
offsetVector3—
offset

The offset to translate by.

Returns Transform3D

The translated matrix.

TranslatedLocalTransform3D
# TranslatedLocal
C#
public Transform3D TranslatedLocal(Vector3 offset);

Returns a copy of this 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.

Parameters
NameTypeDefault
offsetVector3—
offset

The offset to translate by.

Returns Transform3D

The translated matrix.

op_Equalitybool
# op_Equality
C#
public static bool operator ==(Transform3D left, Transform3D right);

Returns true if the transforms are exactly equal. Note: Due to floating-point precision errors, consider using Transform3D.IsEqualApprox instead, which is more reliable.

Parameters
NameTypeDefault
leftTransform3D—
rightTransform3D—
left

The left transform.

right

The right transform.

Returns bool

Whether or not the transforms are exactly equal.

op_Inequalitybool
# op_Inequality
C#
public static bool operator !=(Transform3D left, Transform3D right);

Returns true if the transforms are not equal. Note: Due to floating-point precision errors, consider using Transform3D.IsEqualApprox instead, which is more reliable.

Parameters
NameTypeDefault
leftTransform3D—
rightTransform3D—
left

The left transform.

right

The right transform.

Returns bool

Whether or not the transforms are not equal.

op_Multiply9 overloads
# op_Multiply · 1/9
C#
public static Aabb operator *(Aabb aabb, Transform3D transform);

Returns an AABB transformed (multiplied) by the inverse transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). aabb * transform is equivalent to transform.Inverse() * aabb. See Transform3D.Inverse. For transforming by inverse of an affine transformation (e.g. with scaling) transform.AffineInverse() * aabb can be used instead. See Transform3D.AffineInverse.

Parameters
NameTypeDefault
aabbAabb—
transformTransform3D—
aabb

An AABB to inversely transform.

transform

The transformation to apply.

Returns Aabb

The inversely transformed AABB.

# op_Multiply · 2/9
C#
public static Plane operator *(Plane plane, Transform3D transform);

Returns a Plane transformed (multiplied) by the inverse transformation matrix. plane * transform is equivalent to transform.AffineInverse() * plane. See Transform3D.AffineInverse.

Parameters
NameTypeDefault
planePlane—
transformTransform3D—
plane

A Plane to inversely transform.

transform

The transformation to apply.

Returns Plane

The inversely transformed Plane.

# op_Multiply · 3/9
C#
public static Aabb operator *(Transform3D transform, Aabb aabb);

Returns an AABB transformed (multiplied) by the transformation matrix.

Parameters
NameTypeDefault
transformTransform3D—
aabbAabb—
transform

The transformation to apply.

aabb

An AABB to transform.

Returns Aabb

The transformed AABB.

# op_Multiply · 4/9
C#
public static Plane operator *(Transform3D transform, Plane plane);

Returns a Plane transformed (multiplied) by the transformation matrix.

Parameters
NameTypeDefault
transformTransform3D—
planePlane—
transform

The transformation to apply.

plane

A Plane to transform.

Returns Plane

The transformed Plane.

# op_Multiply · 5/9
C#
public static Transform3D operator *(Transform3D left, Transform3D right);

Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent).

Parameters
NameTypeDefault
leftTransform3D—
rightTransform3D—
left

The parent transform.

right

The child transform.

Returns Transform3D

The composed transform.

# op_Multiply · 6/9
C#
public static Vector3 operator *(Transform3D transform, Vector3 vector);

Returns a Vector3 transformed (multiplied) by the transformation matrix.

Parameters
NameTypeDefault
transformTransform3D—
vectorVector3—
transform

The transformation to apply.

vector

A Vector3 to transform.

Returns Vector3

The transformed Vector3.

# op_Multiply · 7/9
C#
public static Vector3[] operator *(Transform3D transform, Vector3[] array);

Returns a copy of the given Vector3[] transformed (multiplied) by the transformation matrix.

Parameters
NameTypeDefault
transformTransform3D—
arrayVector3[]—
transform

The transformation to apply.

array

A Vector3[] to transform.

Returns Vector3[]

The transformed copy of the Vector3[].

# op_Multiply · 8/9
C#
public static Vector3 operator *(Vector3 vector, Transform3D transform);

Returns a Vector3 transformed (multiplied) by the inverse transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). vector * transform is equivalent to transform.Inverse() * vector. See Transform3D.Inverse. For transforming by inverse of an affine transformation (e.g. with scaling) transform.AffineInverse() * vector can be used instead. See Transform3D.AffineInverse.

Parameters
NameTypeDefault
vectorVector3—
transformTransform3D—
vector

A Vector3 to inversely transform.

transform

The transformation to apply.

Returns Vector3

The inversely transformed Vector3.

# op_Multiply · 9/9
C#
public static Vector3[] operator *(Vector3[] array, Transform3D transform);

Returns a copy of the given Vector3[] transformed (multiplied) by the inverse transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). array * transform is equivalent to transform.Inverse() * array. See Transform3D.Inverse. For transforming by inverse of an affine transformation (e.g. with scaling) transform.AffineInverse() * array can be used instead. See Transform3D.AffineInverse.

Parameters
NameTypeDefault
arrayVector3[]—
transformTransform3D—
array

A Vector3[] to inversely transform.

transform

The transformation to apply.

Returns Vector3[]

The inversely transformed copy of the Vector3[].

Fields and constants2

BasisField
# Basis
C#
public Basis Basis;

The Basis of this transform. It is composed by 3 axes (Basis.X, Basis.Y, and Basis.Z). Together, these represent the transform's rotation, scale, and shear.

OriginField
# Origin
C#
public Vector3 Origin;

The translation offset of this transform. In 3D space, this can be seen as the position.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.