Skip to content

Transform

eduardgushchin edited this page Oct 2, 2026 · 2 revisions

Home | API by Category | Complete API Index | API Status

Field Value
Full name Electron2D.Transform
Namespace Electron2D
Kind struct
Category API Core

Overview

Represents a two-dimensional affine transformation as three column vectors.

Syntax

public struct Electron2D.Transform

Remarks

Electron2D.Transform.X and Electron2D.Transform.Y form the two-by-two basis; Electron2D.Transform.Origin stores translation. The value can represent translation, clockwise rotation in screen coordinates, non-uniform scale, reflection, and skew. The zero-initialized value is a zero matrix, not Electron2D.Transform.Identity.

Detailed engine reference

Members

Member Kind Summary
public Transform(Electron2D.Vector2 xAxis, Electron2D.Vector2 yAxis, Electron2D.Vector2 origin) constructor Initializes a transform from its three matrix columns.
public Transform(System.Single rotation, Electron2D.Vector2 origin) constructor Initializes a rotation and translation transform.
public Transform(System.Single rotation, Electron2D.Vector2 scale, System.Single skew, Electron2D.Vector2 origin) constructor Initializes a transform from rotation, scale, skew, and translation.
public Transform(System.Single xx, System.Single xy, System.Single yx, System.Single yy, System.Single ox, System.Single oy) constructor Initializes a transform from six column-major components.
public Electron2D.Vector2 Origin field Gets or sets the translation offset, which is matrix column two.
public Electron2D.Vector2 X field Gets or sets the basis X axis, which is matrix column zero.
public Electron2D.Vector2 Y field Gets or sets the basis Y axis, which is matrix column one.
public Electron2D.Vector2 this[System.Int32 column] { get; set; } indexer Gets or sets a complete matrix column.
public System.Single this[System.Int32 column, System.Int32 row] { get; set; } indexer Gets or sets one matrix component using column-major coordinates.
public Electron2D.Transform AffineInverse() method Returns the general affine inverse.
public Electron2D.Vector2 BasisXform(Electron2D.Vector2 vector) method Transforms a vector by the basis while ignoring translation.
public Electron2D.Vector2 BasisXformInv(Electron2D.Vector2 vector) method Transforms a vector by the transposed basis while ignoring translation.
public System.Single Determinant() method Returns the determinant of the two-by-two basis.
public virtual System.Boolean Equals(Electron2D.Transform other) method Tests all matrix components for exact equality.
public override System.Boolean Equals(System.Object obj) method Tests whether another object is an exactly equal transform.
public override System.Int32 GetHashCode() method Returns a hash code based on all three columns.
public Electron2D.Transform InterpolateWith(Electron2D.Transform other, System.Single weight) method Interpolates or extrapolates decomposed transform components.
public Electron2D.Transform Inverse() method Returns the fast inverse for an orthonormal basis.
public System.Boolean IsConformal() method Tests whether the basis preserves angles up to uniform scale and optional reflection.
public System.Boolean IsEqualApprox(Electron2D.Transform other) method Tests all three columns for scale-aware approximate equality.
public System.Boolean IsFinite() method Tests whether every matrix component is finite.
public Electron2D.Transform LookingAt(Electron2D.Vector2 target = default) method Returns a rotation-only transform turned toward a target through this transform's affine local space.
public Electron2D.Transform Orthonormalized() method Returns a transform with a Gram-Schmidt orthonormalized basis.
public Electron2D.Transform Rotated(System.Single angle) method Applies a rotation in the global or parent coordinate frame.
public Electron2D.Transform RotatedLocal(System.Single angle) method Applies a rotation in the local coordinate frame.
public Electron2D.Transform Scaled(Electron2D.Vector2 scale) method Applies componentwise scale in the global or parent coordinate frame.
public Electron2D.Transform ScaledLocal(Electron2D.Vector2 scale) method Applies scale in the local coordinate frame.
public override System.String ToString() method Formats the three columns using invariant culture.
public System.String ToString(System.String format) method Formats the three columns with a numeric format and invariant culture.
public Electron2D.Transform Translated(Electron2D.Vector2 offset) method Applies translation in the global or parent coordinate frame.
public Electron2D.Transform TranslatedLocal(Electron2D.Vector2 offset) method Applies translation in the local coordinate frame.
public static Electron2D.Transform op_Division(Electron2D.Transform transform, System.Single scalar) operator Divides every matrix component, including translation, by a scalar.
public static System.Boolean op_Equality(Electron2D.Transform left, Electron2D.Transform right) operator Tests all matrix components for exact equality.
public static System.Boolean op_Inequality(Electron2D.Transform left, Electron2D.Transform right) operator Tests whether any matrix component differs under exact equality.
public static Electron2D.Rect2 op_Multiply(Electron2D.Rect2 rectangle, Electron2D.Transform transform) operator Inverse-transforms a rectangle under an orthonormal-basis precondition.
public static Electron2D.Rect2 op_Multiply(Electron2D.Transform transform, Electron2D.Rect2 rectangle) operator Transforms a rectangle and returns the axis-aligned bounds of its four transformed corners.
public static Electron2D.Transform op_Multiply(Electron2D.Transform left, Electron2D.Transform right) operator Composes a parent transform with a child transform.
public static Electron2D.Vector2 op_Multiply(Electron2D.Transform transform, Electron2D.Vector2 point) operator Transforms a point by the basis and translation.
public static Electron2D.Vector2[] op_Multiply(Electron2D.Transform transform, Electron2D.Vector2[] points) operator Transforms every point into a newly allocated array.
public static Electron2D.Transform op_Multiply(Electron2D.Transform transform, System.Single scalar) operator Multiplies every matrix component, including translation, by a scalar.
public static Electron2D.Vector2 op_Multiply(Electron2D.Vector2 point, Electron2D.Transform transform) operator Applies the inverse orthonormal transform to a point.
public static Electron2D.Vector2[] op_Multiply(Electron2D.Vector2[] points, Electron2D.Transform transform) operator Inverse-transforms every point by an orthonormal transform into a newly allocated array.
public static Electron2D.Transform FlipX { get; } property Gets a transform that reflects across the vertical axis by negating horizontal coordinates.
public static Electron2D.Transform FlipY { get; } property Gets a transform that reflects across the horizontal axis by negating vertical coordinates.
public static Electron2D.Transform Identity { get; } property Gets the identity transform.
public System.Single Rotation { get; } property Gets the clockwise screen-space rotation in radians.
public Electron2D.Vector2 Scale { get; } property Gets the lengths of the basis axes with reflection encoded in the vertical component.
public System.Single Skew { get; } property Gets the angular skew between the basis axes in radians.

Member Details

Transform(Electron2D.Vector2, Electron2D.Vector2, Electron2D.Vector2)

Kind: constructor

public Transform(Electron2D.Vector2 xAxis, Electron2D.Vector2 yAxis, Electron2D.Vector2 origin)

Summary

Initializes a transform from its three matrix columns.

Parameters

  • xAxis: The basis X axis.
  • yAxis: The basis Y axis.
  • origin: The translation offset.

Transform(System.Single, Electron2D.Vector2)

Kind: constructor

public Transform(System.Single rotation, Electron2D.Vector2 origin)

Summary

Initializes a rotation and translation transform.

Parameters

  • rotation: The clockwise screen-space angle in radians.
  • origin: The translation offset.

Transform(System.Single, Electron2D.Vector2, System.Single, Electron2D.Vector2)

Kind: constructor

public Transform(System.Single rotation, Electron2D.Vector2 scale, System.Single skew, Electron2D.Vector2 origin)

Summary

Initializes a transform from rotation, scale, skew, and translation.

Parameters

  • rotation: The clockwise screen-space rotation in radians.
  • scale: The horizontal and vertical scale factors.
  • skew: The angular skew in radians.
  • origin: The translation offset.

Transform(System.Single, System.Single, System.Single, System.Single, System.Single, System.Single)

Kind: constructor

public Transform(System.Single xx, System.Single xy, System.Single yx, System.Single yy, System.Single ox, System.Single oy)

Summary

Initializes a transform from six column-major components.

Parameters

  • xx: The X component of Electron2D.Transform.X.
  • xy: The Y component of Electron2D.Transform.X.
  • yx: The X component of Electron2D.Transform.Y.
  • yy: The Y component of Electron2D.Transform.Y.
  • ox: The X component of Electron2D.Transform.Origin.
  • oy: The Y component of Electron2D.Transform.Origin.

Origin

Kind: field

public Electron2D.Vector2 Origin

Summary

Gets or sets the translation offset, which is matrix column two.

X

Kind: field

public Electron2D.Vector2 X

Summary

Gets or sets the basis X axis, which is matrix column zero.

Remarks

Its length contributes the horizontal scale and its direction defines the transform rotation.

Y

Kind: field

public Electron2D.Vector2 Y

Summary

Gets or sets the basis Y axis, which is matrix column one.

Remarks

Its length contributes the vertical scale and its direction relative to Electron2D.Transform.X defines skew.

Item(System.Int32)

Kind: indexer

public Electron2D.Vector2 this[System.Int32 column] { get; set; }

Summary

Gets or sets a complete matrix column.

Value

The selected column.

Parameters

  • column: Zero for Electron2D.Transform.X, one for Electron2D.Transform.Y, or two for Electron2D.Transform.Origin.

Exceptions

  • T:System.ArgumentOutOfRangeException: column is outside zero through two.

Item(System.Int32, System.Int32)

Kind: indexer

public System.Single this[System.Int32 column, System.Int32 row] { get; set; }

Summary

Gets or sets one matrix component using column-major coordinates.

Value

The selected floating-point component.

Parameters

  • column: The matrix column from zero through two.
  • row: The matrix row, zero for X or one for Y.

Exceptions

  • T:System.ArgumentOutOfRangeException: column is outside zero through two, or row is outside zero through one.

AffineInverse()

Kind: method

public Electron2D.Transform AffineInverse()

Summary

Returns the general affine inverse.

Returns

A transform that composes with this transform to produce the identity, within floating-point precision.

Exceptions

  • T:System.InvalidOperationException: The basis determinant is exactly zero.

BasisXform(Electron2D.Vector2)

Kind: method

public Electron2D.Vector2 BasisXform(Electron2D.Vector2 vector)

Summary

Transforms a vector by the basis while ignoring translation.

Returns

The vector multiplied by the two-by-two basis.

Parameters

  • vector: The vector to transform.

BasisXformInv(Electron2D.Vector2)

Kind: method

public Electron2D.Vector2 BasisXformInv(Electron2D.Vector2 vector)

Summary

Transforms a vector by the transposed basis while ignoring translation.

Remarks

This is the inverse basis transform only when the basis is orthonormal. For scaled or skewed transforms, use transform.AffineInverse().BasisXform(vector).

Returns

The vector multiplied by the transposed basis.

Parameters

  • vector: The vector to transform.

Determinant()

Kind: method

public System.Single Determinant()

Summary

Returns the determinant of the two-by-two basis.

Returns

Zero for a singular basis, a negative value for a reflected basis, or a positive value otherwise.

Equals(Electron2D.Transform)

Kind: method

public virtual System.Boolean Equals(Electron2D.Transform other)

Summary

Tests all matrix components for exact equality.

Returns

true when every corresponding component is exactly equal.

Parameters

  • other: The transform to compare.

Equals(System.Object)

Kind: method

public override System.Boolean Equals(System.Object obj)

Summary

Tests whether another object is an exactly equal transform.

Returns

true when obj is a transform with equal components.

Parameters

  • obj: The object to compare.

GetHashCode()

Kind: method

public override System.Int32 GetHashCode()

Summary

Returns a hash code based on all three columns.

Returns

The component hash code.

InterpolateWith(Electron2D.Transform, System.Single)

Kind: method

public Electron2D.Transform InterpolateWith(Electron2D.Transform other, System.Single weight)

Summary

Interpolates or extrapolates decomposed transform components.

Returns

A transform built from shortest-path angle interpolation, linear scale, skew, and origin interpolation.

Parameters

  • other: The destination transform.
  • weight: The interpolation weight; values outside zero through one extrapolate.

Inverse()

Kind: method

public Electron2D.Transform Inverse()

Summary

Returns the fast inverse for an orthonormal basis.

Remarks

This method assumes rotation or reflection without scale or skew and does not validate that precondition. Use Electron2D.Transform.AffineInverse for a general invertible affine transform.

Returns

The transposed basis and corresponding inverse translation.

IsConformal()

Kind: method

public System.Boolean IsConformal()

Summary

Tests whether the basis preserves angles up to uniform scale and optional reflection.

Returns

true for approximately orthogonal axes of approximately equal length.

IsEqualApprox(Electron2D.Transform)

Kind: method

public System.Boolean IsEqualApprox(Electron2D.Transform other)

Summary

Tests all three columns for scale-aware approximate equality.

Returns

true when every corresponding component is approximately equal.

Parameters

  • other: The transform to compare.

IsFinite()

Kind: method

public System.Boolean IsFinite()

Summary

Tests whether every matrix component is finite.

Returns

true when no component is NaN or infinity.

LookingAt(Electron2D.Vector2)

Kind: method

public Electron2D.Transform LookingAt(Electron2D.Vector2 target = default)

Summary

Returns a rotation-only transform turned toward a target through this transform's affine local space.

Remarks

The target is inverse-transformed and compensated by the signed basis scale before its angle is added to the current rotation. For a skewed source this differs from using the raw global angle from the origin.

Returns

A transform with the same origin and adjusted rotation; scale and skew are removed.

Parameters

  • target: The global target point; defaults to the zero vector.

Exceptions

  • T:System.InvalidOperationException: The basis determinant is exactly zero.

Orthonormalized()

Kind: method

public Electron2D.Transform Orthonormalized()

Summary

Returns a transform with a Gram-Schmidt orthonormalized basis.

Remarks

A zero or linearly dependent axis normalizes to zero instead of producing non-finite components.

Returns

A copy with unit perpendicular axes and the original origin.

Rotated(System.Single)

Kind: method

public Electron2D.Transform Rotated(System.Single angle)

Summary

Applies a rotation in the global or parent coordinate frame.

Returns

The rotation transform multiplied on the left of this transform.

Parameters

  • angle: The clockwise screen-space angle in radians.

RotatedLocal(System.Single)

Kind: method

public Electron2D.Transform RotatedLocal(System.Single angle)

Summary

Applies a rotation in the local coordinate frame.

Returns

The rotation transform multiplied on the right of this transform.

Parameters

  • angle: The clockwise screen-space angle in radians.

Scaled(Electron2D.Vector2)

Kind: method

public Electron2D.Transform Scaled(Electron2D.Vector2 scale)

Summary

Applies componentwise scale in the global or parent coordinate frame.

Returns

A copy whose basis rows and origin are scaled componentwise.

Parameters

  • scale: The scale along global X and Y.

ScaledLocal(Electron2D.Vector2)

Kind: method

public Electron2D.Transform ScaledLocal(Electron2D.Vector2 scale)

Summary

Applies scale in the local coordinate frame.

Returns

A copy whose X and Y columns are multiplied by their corresponding factors.

Parameters

  • scale: The scale along the local basis axes.

ToString()

Kind: method

public override System.String ToString()

Summary

Formats the three columns using invariant culture.

Returns

A string containing the X axis, Y axis, and origin.

ToString(System.String)

Kind: method

public System.String ToString(System.String format)

Summary

Formats the three columns with a numeric format and invariant culture.

Returns

A string containing the X axis, Y axis, and origin.

Parameters

  • format: A standard or custom numeric format, or null for the default format.

Exceptions

  • T:System.FormatException: format is invalid.

Translated(Electron2D.Vector2)

Kind: method

public Electron2D.Transform Translated(Electron2D.Vector2 offset)

Summary

Applies translation in the global or parent coordinate frame.

Returns

A copy with the offset added directly to its origin.

Parameters

  • offset: The global offset.

TranslatedLocal(Electron2D.Vector2)

Kind: method

public Electron2D.Transform TranslatedLocal(Electron2D.Vector2 offset)

Summary

Applies translation in the local coordinate frame.

Returns

A copy with the basis-transformed offset added to its origin.

Parameters

  • offset: The offset expressed in the current basis.

op_Division(Electron2D.Transform, System.Single)

Kind: operator

public static Electron2D.Transform op_Division(Electron2D.Transform transform, System.Single scalar)

Summary

Divides every matrix component, including translation, by a scalar.

Returns

The IEEE 754 componentwise quotient.

Parameters

  • transform: The transform to divide.
  • scalar: The scalar divisor.

op_Equality(Electron2D.Transform, Electron2D.Transform)

Kind: operator

public static System.Boolean op_Equality(Electron2D.Transform left, Electron2D.Transform right)

Summary

Tests all matrix components for exact equality.

Returns

true when every corresponding component is exactly equal.

Parameters

  • left: The first transform.
  • right: The second transform.

op_Inequality(Electron2D.Transform, Electron2D.Transform)

Kind: operator

public static System.Boolean op_Inequality(Electron2D.Transform left, Electron2D.Transform right)

Summary

Tests whether any matrix component differs under exact equality.

Returns

true when at least one corresponding component differs.

Parameters

  • left: The first transform.
  • right: The second transform.

op_Multiply(Electron2D.Rect2, Electron2D.Transform)

Kind: operator

public static Electron2D.Rect2 op_Multiply(Electron2D.Rect2 rectangle, Electron2D.Transform transform)

Summary

Inverse-transforms a rectangle under an orthonormal-basis precondition.

Remarks

This operator is equivalent to transform.Inverse() * rectangle. For scale or skew, use transform.AffineInverse() * rectangle instead.

Returns

The axis-aligned bounds of the inverse-transformed rectangle corners.

Parameters

  • rectangle: The rectangle in transformed coordinates.
  • transform: The orthonormal transform to invert.

op_Multiply(Electron2D.Transform, Electron2D.Rect2)

Kind: operator

public static Electron2D.Rect2 op_Multiply(Electron2D.Transform transform, Electron2D.Rect2 rectangle)

Summary

Transforms a rectangle and returns the axis-aligned bounds of its four transformed corners.

Remarks

Rotation, reflection, non-uniform scale, skew, zero size, and negative size are supported. The result is normalized even when rectangle has a negative size.

Returns

The smallest axis-aligned rectangle enclosing all four transformed corners.

Parameters

  • transform: The affine transform to apply.
  • rectangle: The rectangle to transform.

op_Multiply(Electron2D.Transform, Electron2D.Transform)

Kind: operator

public static Electron2D.Transform op_Multiply(Electron2D.Transform left, Electron2D.Transform right)

Summary

Composes a parent transform with a child transform.

Returns

The composed transform.

Parameters

  • left: The parent transform applied second.
  • right: The child transform applied first.

op_Multiply(Electron2D.Transform, Electron2D.Vector2)

Kind: operator

public static Electron2D.Vector2 op_Multiply(Electron2D.Transform transform, Electron2D.Vector2 point)

Summary

Transforms a point by the basis and translation.

Returns

The transformed point.

Parameters

  • transform: The transform to apply.
  • point: The point in local coordinates.

op_Multiply(Electron2D.Transform, Electron2D.Vector2[])

Kind: operator

public static Electron2D.Vector2[] op_Multiply(Electron2D.Transform transform, Electron2D.Vector2[] points)

Summary

Transforms every point into a newly allocated array.

Returns

A new array containing transformed points in the original order.

Parameters

  • transform: The transform to apply.
  • points: The source points.

Exceptions

  • T:System.ArgumentNullException: points is null.

op_Multiply(Electron2D.Transform, System.Single)

Kind: operator

public static Electron2D.Transform op_Multiply(Electron2D.Transform transform, System.Single scalar)

Summary

Multiplies every matrix component, including translation, by a scalar.

Returns

The componentwise product.

Parameters

  • transform: The transform to scale.
  • scalar: The scalar multiplier.

op_Multiply(Electron2D.Vector2, Electron2D.Transform)

Kind: operator

public static Electron2D.Vector2 op_Multiply(Electron2D.Vector2 point, Electron2D.Transform transform)

Summary

Applies the inverse orthonormal transform to a point.

Remarks

For scale or skew, multiply the point by Electron2D.Transform.AffineInverse instead.

Returns

The point expressed in the transform's local coordinates.

Parameters

  • point: The point in transformed coordinates.
  • transform: The orthonormal transform to invert.

op_Multiply(Electron2D.Vector2[], Electron2D.Transform)

Kind: operator

public static Electron2D.Vector2[] op_Multiply(Electron2D.Vector2[] points, Electron2D.Transform transform)

Summary

Inverse-transforms every point by an orthonormal transform into a newly allocated array.

Remarks

For scale or skew, multiply the points by Electron2D.Transform.AffineInverse instead.

Returns

A new array containing inverse-transformed points in the original order.

Parameters

  • points: The source points.
  • transform: The orthonormal transform to invert.

Exceptions

  • T:System.ArgumentNullException: points is null.

FlipX

Kind: property

public static Electron2D.Transform FlipX { get;  }

Summary

Gets a transform that reflects across the vertical axis by negating horizontal coordinates.

Value

A transform with basis axes (-1, 0) and (0, 1).

FlipY

Kind: property

public static Electron2D.Transform FlipY { get;  }

Summary

Gets a transform that reflects across the horizontal axis by negating vertical coordinates.

Value

A transform with basis axes (1, 0) and (0, -1).

Identity

Kind: property

public static Electron2D.Transform Identity { get;  }

Summary

Gets the identity transform.

Value

A transform with unit basis axes and zero origin.

Rotation

Kind: property

public System.Single Rotation { get;  }

Summary

Gets the clockwise screen-space rotation in radians.

Value

The angle of Electron2D.Transform.X, measured from positive X toward positive Y.

Scale

Kind: property

public Electron2D.Vector2 Scale { get;  }

Summary

Gets the lengths of the basis axes with reflection encoded in the vertical component.

Value

Electron2D.Transform.X length and signed Electron2D.Transform.Y length. A negative determinant makes the vertical component negative; a zero or unordered determinant makes it zero.

Skew

Kind: property

public System.Single Skew { get;  }

Summary

Gets the angular skew between the basis axes in radians.

Value

Zero for an orthogonal basis, with reflection accounted for by the determinant sign.

Clone this wiki locally