• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • API

    Datatypes

    Edit

    Matrix4x4

    Operates as the cornerstone in modeling transformations in 3D space, holding critical data about translations, rotations, and scaling. Think of it as the mathematical blueprint that instructs your 3D objects on how to transform from one state to another – a fundamental tool in creating dynamic and interactive 3D environments. Like a guiding chart for your 3D objects, impacting how they move, turn, and resize in the 3D realm.

    Matrix4x4 section from the official Unity Documentation

    Properties

    Quaternion that represents the rotation part of this matrix. Accessing this property can be particularly useful if you want to extract the rotation information of a Matrix4x4 instance.

    Vector3 representing the scale of the matrix. If the matrix has a uniform scale (the same scale along all axes), 'lossyScale' will correctly report it. If the matrix has a non-uniform scale (different scales along different axes), 'lossyScale' will not accurately reflect it.

    isIdentity

    boolean

    Boolean indicating whether the matrix is the identity matrix. The identity matrix is a special type of matrix that doesn't change any vector when we multiply that vector with it.

    Determinant of the matrix. The determinant is a special number that encapsulates some properties of the matrix. It is used for solving systems of equations, in calculus, and more.

    Inverse of the matrix, assuming it exists. An inverse matrix is a matrix that, when multiplied by the original matrix, yields the identity matrix.

    Transpose of the matrix. The transpose of a matrix is obtained by swapping its rows with columns and vice versa.

    m00

    number

    Element at the first row and first column of the matrix.

    m10

    number

    Element at the second row and first column of the matrix.

    m20

    number

    Element in the third row and first column of the matrix.

    m30

    number

    Element at the fourth row and first column of the matrix.

    m01

    number

    Element in the first row and second column of the matrix.

    m11

    number

    Element at the second row and second column of the matrix.

    m21

    number

    Element at the third row and second column of the matrix.

    m31

    number

    Element in the fourth row and second column of the matrix.

    m02

    number

    Element at the first row and third column of the matrix.

    m12

    number

    Element in the second row and third column of the matrix.

    m22

    number

    Element in the third row and third column of the matrix.

    m32

    number

    Element at the fourth row and third column of the matrix.

    m03

    number

    Element in the first row and fourth column of the matrix.

    m13

    number

    Element at the second row and fourth column of the matrix.

    m23

    number

    Element in the third row and fourth column of the matrix.

    m33

    number

    Element at the fourth row and fourth column of the matrix.

    Matrix4x4 where all elements are set to zero. This essentially signifies a "null" transformation, meaning no change will take place on applying this matrix to a vector or a point.

    Identity Matrix4x4. An identity matrix, when used to transform a point or a vector, leaves it unaltered, just like the number '1' in multiplication. It plays a crucial role in matrix operations and can be very useful for resetting transformations.

    Methods

    Checks if a matrix is a valid transformation matrix. It returns a boolean indicating whether the matrix holds valid translation, rotation, and scale values.

    Returns

    boolean

    Returns true if the matrix is a valid transformation matrix, otherwise false.

    Sets the matrix to a transformation matrix, given a Vector3 for position, a Quaternion for rotation, and a Vector3 for scale. It's quick and convenient when you want to set up a transform from position, rotation and scale values.

    Parameters

    The position to set in the transformation matrix.

    The rotation to set in the transformation matrix.

    The scale to set in the transformation matrix.

    Returns

    void

    Vector4 representing a specified column of the matrix. This can be helpful when you need to extract specific column information from a matrix.

    Parameters

    index

    number

    The index of the column to retrieve.

    Returns

    Vector4

    Returns a Vector4 representing the specified column of the matrix.

    Vector4 representing a specified row of the matrix. This can be useful when you need to extract certain row information from a matrix.

    Parameters

    index

    number

    The index of the row to retrieve.

    Returns

    Vector4

    Returns a Vector4 representing the specified row of the matrix.

    Vector3 representing the position stored in the transformation matrix. This is particularly useful when wanting to extract the position component from a transformation matrix.

    Returns

    Vector3

    Returns a Vector3 representing the position stored in the matrix.

    Vector4 to a specified column of the matrix. This method comes in handy when you want to replace a specific column of a matrix.

    Parameters

    index

    number

    The index of the column to set.

    column
    Vector4

    The vector to set in the specified column of the matrix.

    Returns

    void

    Vector4 to a specified row of the matrix. You can use this method to replace a certain row of a matrix.

    Parameters

    index

    number

    The index of the row to set.

    The vector to set in the specified row of the matrix.

    Returns

    void

    Multiplies a Matrix4x4 and a Vector3 together. It treats the input Vector3 as a point in 3D space - this means it also considers the translation stored in the matrix.

    Parameters

    point
    Vector3

    The vector to be multiplied with the matrix.

    Returns

    Vector3

    Returns a Vector3 as a result of the multiplication.

    Multiplies a Matrix4x4 and a Vector3 together. It treats the matrix as if it's a 3x4 matrix, and thus the result will not have perspective projection applied.

    Parameters

    point
    Vector3

    The vector to be multiplied with the matrix.

    Returns

    Vector3

    Returns a Vector3 as a result of the multiplication without perspective projection.

    Multiplies a Matrix4x4 and a Vector3 together. It treats the input Vector3 as a direction rather than a point, meaning it will not consider the translation part of the matrix.

    Parameters

    vector
    Vector3

    The vector to be multiplied with the matrix.

    Returns

    Vector3

    Returns a Vector3 as a result of the multiplication.

    Determinant of a given Matrix4x4. The determinant of a matrix is a special scalar value that can be computed from its elements and can provide useful information about the matrix.

    Parameters

    The matrix whose determinant is to be calculated.

    Returns

    number

    Returns the determinant of the given matrix.

    Creates a transformation matrix from translation, rotation, and scale. The 'TRS' stands for 'Translate, Rotate, Scale'. It returns a Matrix4x4 built from the given Vector3 of position, Quaternion of rotation and another Vector3 of scale.

    Parameters

    The position to be included in the transformation matrix.

    The rotation to be included in the transformation matrix.

    The scale to be included in the transformation matrix.

    Returns

    Matrix4x4

    Returns a Matrix4x4 transformation matrix created from a position, rotation, and scale.

    Computes the inverse of a given Matrix4x4. The inverse of a matrix is a matrix that, when multiplied with the original matrix, yields the identity matrix.

    Parameters

    The matrix to be inversed.

    Returns

    Matrix4x4

    Returns the inverse of the given matrix.

    Creates the transpose of a given Matrix4x4. The transpose of a matrix is a new matrix whose rows are the columns of the original matrix and whose columns are the original's rows.

    Parameters

    The matrix to be transposed.

    Returns

    Matrix4x4

    Returns the transpose of the given matrix.

    Creates an orthogonal projection matrix. The resulting matrix can be used to transform coordinates in 3D into a 2D projection. This is particularly useful in things like 2D games or interfaces.

    Parameters

    left

    number

    The value for the left vertical clipping plane.

    right

    number

    The value for the right vertical clipping plane.

    bottom

    number

    The value for the bottom horizontal clipping plane.

    top

    number

    The value for the top horizontal clipping plane.

    zNear

    number

    The value for the near depth clipping plane.

    zFar

    number

    The value for the far depth clipping plane.

    Returns

    Matrix4x4

    Returns an orthogonal projection matrix created from the specified parameters.

    Creates a perspective projection matrix from field of view, aspect ratio, and near and far clipping planes. The resulting matrix can be used to transform 3D coordinates into a 2D perspective.

    Parameters

    fov

    number

    The field of view in the y direction, measured in degrees.

    aspect

    number

    The aspect ratio, defined as width divided by height.

    zNear

    number

    The value for the near depth clipping plane.

    zFar

    number

    The value for the far depth clipping plane.

    Returns

    Matrix4x4

    Returns a perspective projection matrix created from the specified parameters.

    Creates a viewing matrix aimed at a target with a defined up direction. This method can be useful in a variety of situations, like setting the view matrix of a camera.

    Parameters

    The position the result matrix will transform from.

    The target point the result matrix will face towards.

    The up direction. It must not be parallel to the direction vector pointing from 'from' to 'to'.

    Returns

    Matrix4x4

    Returns a viewing matrix aimed at the target from a set position and up direction.

    Creates a perspective projection matrix that represents a view frustum. A frustum is a kind of pyramid with its top cut off. It is typically what a camera in 3D space sees with certain field of view and near and far clipping planes.

    Parameters

    left

    number

    The value for the left vertical clipping plane.

    right

    number

    The value for the right vertical clipping plane.

    bottom

    number

    The value for the bottom horizontal clipping plane.

    top

    number

    The value for the top horizontal clipping plane.

    zNear

    number

    The value for the near depth clipping plane.

    zFar

    number

    The value for the far depth clipping plane.

    Returns

    Matrix4x4

    Returns a perspective projection matrix that represents the specified view frustum.

    Creates a scaling matrix from a given Vector3. The resulting matrix can be used to scale an object in 3D space by the specified vector.

    Parameters

    vector
    Vector3

    The vector by which to scale.

    Returns

    Matrix4x4

    Returns a scaling matrix created from the specified vector.

    Creates a translation matrix from a given Vector3. It can be used to move an object in 3D space by a specified vector.

    Parameters

    vector
    Vector3

    The vector by which to translate.

    Returns

    Matrix4x4

    Returns a translation matrix created from the specified vector.

    Creates a rotation matrix from a Quaternion. The resulting matrix can be used to rotate an object in 3D space by the specified Quaternion.

    Parameters

    The quaternion by which to rotate.

    Returns

    Matrix4x4

    Returns a rotation matrix created from the specified quaternion.

    Updated 4 months ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.