Class (GI Struct)

Graphene-1.0GrapheneMatrix

A structure capable of holding a 4x4 matrix.

The contents of the Graphene.Matrix structure are private and should never be accessed directly.

Index

Constructors

Properties

Methods

  • Checks whether the two given Graphene.Matrix matrices are byte-by-byte equal.

    While this function is faster than graphene_matrix_equal(), it can also return false negatives, so it should be used in conjuction with either graphene_matrix_equal() or graphene_matrix_near(). For instance:

      if (graphene_matrix_equal_fast (a, b))
    {
    // matrices are definitely the same
    }
    else
    {
    if (graphene_matrix_equal (a, b))
    // matrices contain the same values within an epsilon of FLT_EPSILON
    else if (graphene_matrix_near (a, b, 0.0001))
    // matrices contain the same values within an epsilon of 0.0001
    else
    // matrices are not equal
    }

    Returns boolean

    true if the matrices are equal. and false otherwise

  • Retrieves the given row vector at index_ inside a matrix.

    Parameters

    • index_: number

      the index of the row vector, between 0 and 3

    Returns Vec4

  • Retrieves the value at the given row and col index.

    Parameters

    • row: number

      the row index

    • col: number

      the column index

    Returns number

    the value at the given indices

  • Initializes a Graphene.Matrix from the values of an affine transformation matrix.

    The arguments map to the following matrix layout:

    xx  yx ⎞   ⎛  a   b  0
    xy yy ⎟ = ⎜ c d 0
    x0 y0 ⎠ ⎝ tx ty 1

    This function can be used to convert between an affine matrix type from other libraries and a Graphene.Matrix.

    Parameters

    • xx: number

      the xx member

    • yx: number

      the yx member

    • xy: number

      the xy member

    • yy: number

      the yy member

    • x_0: number

      the x0 member

    • y_0: number

      the y0 member

    Returns Graphene.Matrix

    the initialized matrix

  • Initializes a Graphene.Matrix compatible with Graphene.Frustum.

    See also: graphene_frustum_init_from_matrix()

    Parameters

    • left: number

      distance of the left clipping plane

    • right: number

      distance of the right clipping plane

    • bottom: number

      distance of the bottom clipping plane

    • top: number

      distance of the top clipping plane

    • z_near: number

      distance of the near clipping plane

    • z_far: number

      distance of the far clipping plane

    Returns Graphene.Matrix

    the initialized matrix

  • Initializes a Graphene.Matrix so that it positions the "camera" at the given eye coordinates towards an object at the center coordinates. The top of the camera is aligned to the direction of the up vector.

    Before the transform, the camera is assumed to be placed at the origin, looking towards the negative Z axis, with the top side of the camera facing in the direction of the Y axis and the right side in the direction of the X axis.

    In theory, one could use m to transform a model of such a camera into world-space. However, it is more common to use the inverse of m to transform another object from world coordinates to the view coordinates of the camera. Typically you would then apply the camera projection transform to get from view to screen coordinates.

    Parameters

    • eye: Vec3

      the vector describing the position to look from

    • center: Vec3

      the vector describing the position to look at

    • up: Vec3

      the vector describing the world's upward direction; usually, this is the graphene_vec3_y_axis() vector

    Returns Graphene.Matrix

    the initialized matrix

  • Initializes a Graphene.Matrix with an orthographic projection.

    Parameters

    • left: number

      the left edge of the clipping plane

    • right: number

      the right edge of the clipping plane

    • top: number

      the top edge of the clipping plane

    • bottom: number

      the bottom edge of the clipping plane

    • z_near: number

      the distance of the near clipping plane

    • z_far: number

      the distance of the far clipping plane

    Returns Graphene.Matrix

    the initialized matrix

  • Initializes a Graphene.Matrix with a perspective projection.

    Parameters

    • fovy: number

      the field of view angle, in degrees

    • aspect: number

      the aspect value

    • z_near: number

      the near Z plane

    • z_far: number

      the far Z plane

    Returns Graphene.Matrix

    the initialized matrix

  • Prints the contents of a matrix to the standard error stream.

    This function is only useful for debugging; there are no guarantees made on the format of the output.

    Returns void

  • Adds a rotation transformation to m, using the given angle and axis vector.

    This is the equivalent of calling graphene_matrix_init_rotate() and then multiplying the matrix m with the rotation matrix.

    Parameters

    • angle: number

      the rotation angle, in degrees

    • axis: Vec3

      the rotation axis, as a Graphene.Vec3

    Returns void

  • Adds a rotation transformation around the X axis to m, using the given angle.

    See also: graphene_matrix_rotate()

    Parameters

    • angle: number

      the rotation angle, in degrees

    Returns void

  • Adds a rotation transformation around the Y axis to m, using the given angle.

    See also: graphene_matrix_rotate()

    Parameters

    • angle: number

      the rotation angle, in degrees

    Returns void

  • Adds a rotation transformation around the Z axis to m, using the given angle.

    See also: graphene_matrix_rotate()

    Parameters

    • angle: number

      the rotation angle, in degrees

    Returns void

  • Adds a scaling transformation to m, using the three given factors.

    This is the equivalent of calling graphene_matrix_init_scale() and then multiplying the matrix m with the scale matrix.

    Parameters

    • factor_x: number

      scaling factor on the X axis

    • factor_y: number

      scaling factor on the Y axis

    • factor_z: number

      scaling factor on the Z axis

    Returns void

  • Adds a skew of factor on the X and Y axis to the given matrix.

    Parameters

    • factor: number

      skew factor

    Returns void

  • Adds a skew of factor on the X and Z axis to the given matrix.

    Parameters

    • factor: number

      skew factor

    Returns void

  • Adds a skew of factor on the Y and Z axis to the given matrix.

    Parameters

    • factor: number

      skew factor

    Returns void

  • Converts a Graphene.Matrix to an affine transformation matrix, if the given matrix is compatible.

    The returned values have the following layout:

    xx  yx ⎞   ⎛  a   b  0
    xy yy ⎟ = ⎜ c d 0
    x0 y0 ⎠ ⎝ tx ty 1

    This function can be used to convert between a Graphene.Matrix and an affine matrix type from other libraries.

    Returns [boolean, number, number, number, number, number, number]

    true if the matrix is compatible with an affine transformation matrix