docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct Matrix2D

    A 2x3 transformation matrix used for 2D operations.

    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.VectorGraphics
    Assembly: Unity.VectorGraphics.dll
    Syntax
    public struct Matrix2D

    Constructors

    Matrix2D(Vector2, Vector2, Vector2)

    Initializes a Matrix2D with column vectors

    Declaration
    public Matrix2D(Vector2 column0, Vector2 column1, Vector2 column2)
    Parameters
    Type Name Description
    Vector2 column0

    The first column

    Vector2 column1

    The second column

    Vector2 column2

    The third column

    Fields

    m00

    The matrix member at (0,0)

    Declaration
    public float m00
    Field Value
    Type Description
    float

    m01

    The matrix member at (0,1)

    Declaration
    public float m01
    Field Value
    Type Description
    float

    m02

    The matrix member at (0,2)

    Declaration
    public float m02
    Field Value
    Type Description
    float

    m10

    The matrix member at (1,0)

    Declaration
    public float m10
    Field Value
    Type Description
    float

    m11

    The matrix member at (1,1)

    Declaration
    public float m11
    Field Value
    Type Description
    float

    m12

    The matrix member at (1,2)

    Declaration
    public float m12
    Field Value
    Type Description
    float

    Properties

    this[int]

    Access element at sequential index (0..5 inclusive).

    Declaration
    public float this[int index] { get; set; }
    Parameters
    Type Name Description
    int index
    Property Value
    Type Description
    float

    The value at [index]

    this[int, int]

    Access element at [row, column].

    Declaration
    public float this[int row, int column] { get; set; }
    Parameters
    Type Name Description
    int row
    int column
    Property Value
    Type Description
    float

    The value at [row, column]

    identity

    Returns the identity matrix (read-only).

    Declaration
    public static Matrix2D identity { get; }
    Property Value
    Type Description
    Matrix2D

    The identity matrix

    zero

    Returns a matrix with all elements set to zero (read-only).

    Declaration
    public static Matrix2D zero { get; }
    Property Value
    Type Description
    Matrix2D

    The zero matrix

    Methods

    Equals(object)

    Checks if two matrices are equal.

    Declaration
    public override bool Equals(object other)
    Parameters
    Type Name Description
    object other

    The other matrix to compare with

    Returns
    Type Description
    bool

    True when the matrix is equal to "other"

    Overrides
    ValueType.Equals(object)
    Remarks

    Used to allow Matrix3x3s to be used as keys in hash tables.

    GetColumn(int)

    Gets a column of the matrix.

    Declaration
    public Vector2 GetColumn(int index)
    Parameters
    Type Name Description
    int index

    The column index, between 0 and 2 inclusively

    Returns
    Type Description
    Vector2

    The column at "index"

    GetHashCode()

    Gets a hashcode of the matrix.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    The hashcode of the matrix

    Overrides
    ValueType.GetHashCode()
    Remarks

    Used to allow Matrix3x3s to be used as keys in hash tables.

    GetRow(int)

    Gets a row of the matrix.

    Declaration
    public Vector3 GetRow(int index)
    Parameters
    Type Name Description
    int index

    The row index, between 0 and 1 inclusively

    Returns
    Type Description
    Vector3

    The row at "index"

    Inverse()

    Computes the inverse of the matrix.

    Declaration
    public Matrix2D Inverse()
    Returns
    Type Description
    Matrix2D

    The inverse matrix

    MultiplyPoint(Vector2)

    Transforms a position by this matrix (effectively by 2x3).

    Declaration
    public Vector2 MultiplyPoint(Vector2 point)
    Parameters
    Type Name Description
    Vector2 point

    The point to multiply with this matrix

    Returns
    Type Description
    Vector2

    The multiplied point

    MultiplyVector(Vector2)

    Transforms a direction by this matrix.

    Declaration
    public Vector2 MultiplyVector(Vector2 vector)
    Parameters
    Type Name Description
    Vector2 vector

    The direction to multiply with this matrix

    Returns
    Type Description
    Vector2

    The multiplied direction

    RotateLH(float)

    Creates a left-hand side rotation matrix.

    Declaration
    public static Matrix2D RotateLH(float angleRadians)
    Parameters
    Type Name Description
    float angleRadians

    The rotation angle, in radians

    Returns
    Type Description
    Matrix2D

    The rotation matrix

    RotateRH(float)

    Creates a right-hand side rotation matrix.

    Declaration
    public static Matrix2D RotateRH(float angleRadians)
    Parameters
    Type Name Description
    float angleRadians

    The rotation angle, in radians

    Returns
    Type Description
    Matrix2D

    The rotation matrix

    Scale(Vector2)

    Creates a scaling matrix.

    Declaration
    public static Matrix2D Scale(Vector2 vector)
    Parameters
    Type Name Description
    Vector2 vector

    The scaling vector

    Returns
    Type Description
    Matrix2D

    The scaling matrix

    SetColumn(int, Vector2)

    Sets a column of the matrix.

    Declaration
    public void SetColumn(int index, Vector2 column)
    Parameters
    Type Name Description
    int index

    The column index, between 0 and 2 inclusively

    Vector2 column

    The column

    SetRow(int, Vector3)

    Sets a row of the matrix.

    Declaration
    public void SetRow(int index, Vector3 row)
    Parameters
    Type Name Description
    int index

    The column index, between 0 and 1 inclusively

    Vector3 row

    The row

    SkewX(float)

    Creates a skew matrix on X.

    Declaration
    public static Matrix2D SkewX(float angleRadians)
    Parameters
    Type Name Description
    float angleRadians

    The skew angle, in radians

    Returns
    Type Description
    Matrix2D

    The skew matrix

    SkewY(float)

    Creates a skew matrix on U.

    Declaration
    public static Matrix2D SkewY(float angleRadians)
    Parameters
    Type Name Description
    float angleRadians

    The skew angle, in radians

    Returns
    Type Description
    Matrix2D

    The skew matrix

    ToString()

    Returns a string representation of the matrix.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The matrix string representation

    Overrides
    ValueType.ToString()

    ToString(string)

    Returns a string representation of the matrix using a format.

    Declaration
    public string ToString(string format)
    Parameters
    Type Name Description
    string format

    The format to be used for the matrix components

    Returns
    Type Description
    string

    The matrix string representation

    Translate(Vector2)

    Creates a translation matrix.

    Declaration
    public static Matrix2D Translate(Vector2 vector)
    Parameters
    Type Name Description
    Vector2 vector

    The translation vector

    Returns
    Type Description
    Matrix2D

    The translation matrix

    Operators

    operator ==(Matrix2D, Matrix2D)

    Checks if two matrices are equal.

    Declaration
    public static bool operator ==(Matrix2D lhs, Matrix2D rhs)
    Parameters
    Type Name Description
    Matrix2D lhs

    The left hand side matrix of the comparison

    Matrix2D rhs

    The right hand side matrix of the comparison

    Returns
    Type Description
    bool

    True if "lhs" and "rhs" are equal, or false otherwise.

    operator !=(Matrix2D, Matrix2D)

    Checks if two matrices are not equal.

    Declaration
    public static bool operator !=(Matrix2D lhs, Matrix2D rhs)
    Parameters
    Type Name Description
    Matrix2D lhs

    The left hand side matrix of the comparison

    Matrix2D rhs

    The right hand side matrix of the comparison

    Returns
    Type Description
    bool

    True if "lhs" and "rhs" not are equal, or false otherwise.

    operator *(Matrix2D, Matrix2D)

    Multiplies two matrices.

    Declaration
    public static Matrix2D operator *(Matrix2D lhs, Matrix2D rhs)
    Parameters
    Type Name Description
    Matrix2D lhs

    The left hand side matrix of the operation

    Matrix2D rhs

    The right hand side matrix of the operation

    Returns
    Type Description
    Matrix2D

    The multiplied matrix

    operator *(Matrix2D, Vector2)

    Transforms a Vector2 by a matrix.

    Declaration
    public static Vector2 operator *(Matrix2D lhs, Vector2 vector)
    Parameters
    Type Name Description
    Matrix2D lhs

    The left hand side matrix of the operation

    Vector2 vector

    The vector the matrix will be multiplied with

    Returns
    Type Description
    Vector2

    The transformed vector

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)