reckfellENGINE

Transform2D

Two axes and translation for a 2D transform.

On this page
struct Transform2DReckfellSharpInherits ValueType

transform × point applies both axes and Origin. In parent × child composition, the right transform acts first. Positive rotation appears clockwise in ordinary screen 2D because Y points down.

Inverse and point × transform assume an orthonormal basis. Use AffineInverse for invertible scale. Zero determinant means no inverse. This is a C# struct: assign a modified copy back to the Entity property.

Practical guide.

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

Constructors4

Transform2D4 overloads
# Transform2D · 1/4
C#
public Transform2D(Vector2 xAxis, Vector2 yAxis, Vector2 originPos);

Creates a transform from two basis columns and a translation. xAxis and yAxis are columns, not matrix rows.

Parameters
NameTypeDefault
xAxisVector2—
yAxisVector2—
originPosVector2—
xAxis

First basis column.

yAxis

Second basis column.

originPos

Origin translation.

# Transform2D · 2/4
C#
public Transform2D(float rotation, Vector2 origin);

Creates a transform from a rotation in radians and a translation. The basis has unit scale and no skew; positive rotation turns Right toward Down in ordinary 2D.

Parameters
NameTypeDefault
rotationfloat—
originVector2—
rotation

Rotation in radians.

origin

Origin translation.

# Transform2D · 3/4
C#
public Transform2D(float rotation, Vector2 scale, float skew, Vector2 origin);

Creates a transform from rotation, scale, skew and translation. Rotation and skew are in radians; zero scale can make the basis noninvertible.

Parameters
NameTypeDefault
rotationfloat—
scaleVector2—
skewfloat—
originVector2—
rotation

Rotation in radians.

scale

Scale along the local X and Y axes.

skew

Skew in radians.

origin

Origin translation.

# Transform2D · 4/4
C#
public Transform2D(float xx, float xy, float yx, float yy, float ox, float oy);

Constructs a Transform2D from 3 Vector2 values representing Transform2D.X, Transform2D.Y, and the Transform2D.Origin (the three matrix columns).

Parameters
NameTypeDefault
xxfloat—
xyfloat—
yxfloat—
yyfloat—
oxfloat—
oyfloat—
xx

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

xy

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

yx

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

yy

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

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].

Properties8

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

When any transform is multiplied by Transform2D.FlipX, it negates all components of the Transform2D.X axis (the X column). When Transform2D.FlipX is multiplied by any transform, it negates the Vector2.X component of all axes (the X row).

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

When any transform is multiplied by Transform2D.FlipY, it negates all components of the Transform2D.Y axis (the Y column). When Transform2D.FlipY is multiplied by any transform, it negates the Vector2.Y component of all axes (the Y row).

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

Identity transform without translation, rotation or scale change. In C#, parameterless new Transform2D() contains zeros and is not a substitute for Identity.

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

Access whole columns in the form of Vector2. The third column is the Transform2D.Origin vector.

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

Access matrix elements in column-major order. The third column is the Transform2D.Origin vector.

RotationProperty
# Rotation
C#
public float Rotation { get; }

Returns the transform's rotation (in radians).

ScaleProperty
# Scale
C#
public Vector2 Scale { get; }

Returns the scale.

SkewProperty
# Skew
C#
public float Skew { get; }

Returns the transform's skew (in radians).

Methods29

AffineInverseTransform2D
# AffineInverse
C#
public Transform2D AffineInverse();

Returns an affine inverse including scale. The determinant must be nonzero; an exactly zero determinant throws InvalidOperationException.

Returns Transform2D

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

BasisXformVector2
# BasisXform
C#
public Vector2 BasisXform(Vector2 v);

Transforms a vector by the basis without Origin translation. Scale and skew still apply; normalize separately when a unit direction is required.

Parameters
NameTypeDefault
vVector2—
v

Vector without positional translation.

Returns Vector2

Basis-transformed vector, without translation.

BasisXformInvVector2
# BasisXformInv
C#
public Vector2 BasisXformInv(Vector2 v);

Applies the transposed basis without translation. This is an inverse only for an orthonormal basis; with scale or skew use AffineInverse().BasisXform(v).

Parameters
NameTypeDefault
vVector2—
v

Vector without positional translation.

Returns Vector2

Vector transformed by the transposed basis; a correct inverse result requires orthonormality.

Determinantfloat
# Determinant
C#
public float Determinant();

Returns the basis determinant X.X * Y.Y - X.Y * Y.X. Zero means noninvertible, a negative value reverses orientation; translation does not affect the result.

Returns float

Signed basis determinant, excluding Origin.

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

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

Parameters
NameTypeDefault
otherTransform2D—
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 Transform2D.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 Transform2D.

Returns int

A hash code for this transform.

InterpolateWithTransform2D
# InterpolateWith
C#
public Transform2D InterpolateWith(Transform2D 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
transformTransform2D—
weightfloat—
transform

The other transform.

weight

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

Returns Transform2D

The interpolated transform.

InverseTransform2D
# Inverse
C#
public Transform2D Inverse();

Fast inverse for orthonormal axes. Use AffineInverse for invertible scale.

Returns Transform2D

The inverse matrix.

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

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

Parameters
NameTypeDefault
otherTransform2D—
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.

OrthonormalizedTransform2D
# Orthonormalized
C#
public Transform2D Orthonormalized();

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

Returns Transform2D

The orthonormalized transform.

RotatedTransform2D
# Rotated
C#
public Transform2D Rotated(float angle);

Returns a copy of this transform rotated by the given angle (in radians). If angle is positive, the transform is rotated clockwise. 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.

Parameters
NameTypeDefault
anglefloat—
angle

The angle to rotate, in radians.

Returns Transform2D

The rotated transformation matrix.

RotatedLocalTransform2D
# RotatedLocal
C#
public Transform2D RotatedLocal(float angle);

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.

Parameters
NameTypeDefault
anglefloat—
angle

The angle to rotate, in radians.

Returns Transform2D

The rotated transformation matrix.

ScaledTransform2D
# Scaled
C#
public Transform2D Scaled(Vector2 scale);

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.

Parameters
NameTypeDefault
scaleVector2—
scale

The scale to introduce.

Returns Transform2D

The scaled transformation matrix.

ScaledLocalTransform2D
# ScaledLocal
C#
public Transform2D ScaledLocal(Vector2 scale);

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.

Parameters
NameTypeDefault
scaleVector2—
scale

The scale to introduce.

Returns Transform2D

The scaled transformation matrix.

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

Converts this Transform2D to a string.

Returns string

A string representation of this transform.

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

Converts this Transform2D to a string with the given format.

Parameters
NameTypeDefault
formatstring—
Returns string

A string representation of this transform.

TranslatedTransform2D
# Translated
C#
public Transform2D Translated(Vector2 offset);

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.

Parameters
NameTypeDefault
offsetVector2—
offset

The offset to translate by.

Returns Transform2D

The translated matrix.

TranslatedLocalTransform2D
# TranslatedLocal
C#
public Transform2D TranslatedLocal(Vector2 offset);

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.

Parameters
NameTypeDefault
offsetVector2—
offset

The offset to translate by.

Returns Transform2D

The translated matrix.

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

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

Parameters
NameTypeDefault
leftTransform2D—
rightTransform2D—
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 !=(Transform2D left, Transform2D right);

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

Parameters
NameTypeDefault
leftTransform2D—
rightTransform2D—
left

The left transform.

right

The right transform.

Returns bool

Whether or not the transforms are not equal.

op_Multiply7 overloads
# op_Multiply · 1/7
C#
public static Rect2 operator *(Rect2 rect, Transform2D transform);

Returns a Rect2 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). rect * transform is equivalent to transform.Inverse() * rect. See Transform2D.Inverse. For transforming by inverse of an affine transformation (e.g. with scaling) transform.AffineInverse() * rect can be used instead. See Transform2D.AffineInverse.

Parameters
NameTypeDefault
rectRect2—
transformTransform2D—
rect

A Rect2 to inversely transform.

transform

The transformation to apply.

Returns Rect2

The inversely transformed Rect2.

# op_Multiply · 2/7
C#
public static Rect2 operator *(Transform2D transform, Rect2 rect);

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

Parameters
NameTypeDefault
transformTransform2D—
rectRect2—
transform

The transformation to apply.

rect

A Rect2 to transform.

Returns Rect2

The transformed Rect2.

# op_Multiply · 3/7
C#
public static Transform2D operator *(Transform2D left, Transform2D right);

Composes transforms: left * right applies right first, then left. For a hierarchy this is the parent transform multiplied by the child transform.

Parameters
NameTypeDefault
leftTransform2D—
rightTransform2D—
left

Outer transform, applied second.

right

Inner transform, applied first.

Returns Transform2D

Composed transform left * right.

# op_Multiply · 4/7
C#
public static Vector2 operator *(Transform2D transform, Vector2 vector);

Transforms a point by the basis and adds Origin. For a direction without translation use BasisXform.

Parameters
NameTypeDefault
transformTransform2D—
vectorVector2—
transform

Transform; reversed order with Vector2 requires an orthonormal basis.

vector

Point in the source coordinate system.

Returns Vector2

Point in the destination space, subject to this operator's basis requirements.

# op_Multiply · 5/7
C#
public static Vector2[] operator *(Transform2D transform, Vector2[] array);

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

Parameters
NameTypeDefault
transformTransform2D—
arrayVector2[]—
transform

The transformation to apply.

array

A Vector2[] to transform.

Returns Vector2[]

The transformed copy of the Vector2[].

# op_Multiply · 6/7
C#
public static Vector2 operator *(Vector2 vector, Transform2D transform);

Inverse-transforms a point assuming an orthonormal basis. With scale or skew this operand order does not replace transform.AffineInverse() * vector.

Parameters
NameTypeDefault
vectorVector2—
transformTransform2D—
vector

Point in the source coordinate system.

transform

Transform; reversed order with Vector2 requires an orthonormal basis.

Returns Vector2

Point in the destination space, subject to this operator's basis requirements.

# op_Multiply · 7/7
C#
public static Vector2[] operator *(Vector2[] array, Transform2D transform);

Returns a copy of the given Vector2[] 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 Transform2D.Inverse. For transforming by inverse of an affine transformation (e.g. with scaling) transform.AffineInverse() * array can be used instead. See Transform2D.AffineInverse.

Parameters
NameTypeDefault
arrayVector2[]—
transformTransform2D—
array

A Vector2[] to inversely transform.

transform

The transformation to apply.

Returns Vector2[]

The inversely transformed copy of the Vector2[].

Fields and constants3

OriginField
# Origin
C#
public Vector2 Origin;

Translation applied when transforming a point. BasisXform applies only the basis and does not add Origin.

XField
# X
C#
public Vector2 X;

First basis column: the transformed local X axis. Does not include Origin translation.

YField
# Y
C#
public Vector2 Y;

Second basis column: the transformed local Y axis. In ordinary 2D coordinates positive Y points down.

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.