2D Transformation. 3x2 matrix.
public struct Transform2D : IEquatable<Transform2D>

Represents one or many transformations in 2D space such as translation, rotation, or scaling. It consists of a two Vector2 x, y and Vector2 “origin”. It is similar to a 3x2 matrix.

Static Properties

public static  FlipX { get; }

public static  FlipY { get; }

public static  Identity { get; }

Constructors

public Transform2D(Vector2 xAxis, Vector2 yAxis, Vector2 originPos)

Constructs the transform from 3 Vector2s representing x, y, and origin.

public Transform2D(float xx, float xy, float yx, float yy, float ox, float oy)

public Transform2D(float rot, Vector2 pos)

Constructs the transform from a given angle (in radians) and position.

public Transform2D()

Fields

public Vector2 origin

The transform’s translation offset.

public Vector2 x

The X axis of 2x2 basis matrix containing 2 Vector2s as its columns: X axis and Y axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object.

public Vector2 y

The Y axis of 2x2 basis matrix containing 2 Vector2s as its columns: X axis and Y axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object.

Properties

public float Rotation { get; set; }

public Vector2 Scale { get; set; }

public Vector2 this[] { get; set; }

public float this[] { get; set; }

Methods

public Transform2D AffineInverse()

Returns the inverse of the matrix.

public Vector2 BasisXform(Vector2 v)

Transforms the given vector by this transform’s basis (no translation).

public Vector2 BasisXformInv(Vector2 v)

Inverse-transforms the given vector by this transform’s basis (no translation).

public override bool Equals(object obj)

public bool Equals(Transform2D other)

public override int GetHashCode()

public Transform2D InterpolateWith(Transform2D m, float c)

Returns a transform interpolated between this transform and another by a given weight (0-1).

public Transform2D Inverse()

Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling).

public Transform2D Orthonormalized()

Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors.

public Transform2D Rotated(float phi)

Rotates the transform by the given angle (in radians).

public Transform2D Scaled(Vector2 scale)

Scales the transform by the given factor.

public override string ToString()

public string ToString(string format)

public Transform2D Translated(Vector2 offset)

Translates the transform by the given offset.

public Vector2 Xform(Vector2 v)

public Vector2 XformInv(Vector2 v)

Operators

public static bool operator ==(Transform2D left, Transform2D right)

public static bool operator !=(Transform2D left, Transform2D right)

public static Transform2D operator *(Transform2D left, Transform2D right)
Tags: