Gjsify LogoGjsify Logo

A structure capable of holding a 4x4 matrix.

The contents of the #graphene_matrix_t structure are private and should never be accessed directly.

record

Hierarchy

  • Matrix

Index

Constructors

Properties

name: string

Methods

  • determinant(): number
  • Checks whether the two given #graphene_matrix_t 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
    }

    Parameters

    Returns boolean

  • free(): void
  • getRow(index: number): Vec4
  • 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

  • getValue(row: number, col: number): number
  • Retrieves the value at the given row and col index.

    Parameters

    • row: number

      the row index

    • col: number

      the column index

    Returns number

  • getXScale(): number
  • getXTranslation(): number
  • Retrieves the translation component on the X axis from m.

    Returns number

  • getYScale(): number
  • getYTranslation(): number
  • Retrieves the translation component on the Y axis from m.

    Returns number

  • getZScale(): number
  • getZTranslation(): number
  • Retrieves the translation component on the Z axis from m.

    Returns number

  • initFrom2d(xx: number, yx: number, xy: number, yy: number, x0: number, y0: number): Graphene.Matrix
  • Initializes a #graphene_matrix_t 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_t.
    @param xx the xx member
    @param yx the yx member
    @param xy the xy member
    @param yy the yy member
    @param x0 the x0 member
    @param y0 the y0 member

    Parameters

    • xx: number
    • yx: number
    • xy: number
    • yy: number
    • x0: number
    • y0: number

    Returns Graphene.Matrix

  • Initializes a #graphene_matrix_t with the given array of floating point values.

    Parameters

    • v: number[]

      an array of at least 16 floating point values

    Returns Graphene.Matrix

  • initFrustum(left: number, right: number, bottom: number, top: number, zNear: number, zFar: number): Graphene.Matrix
  • Initializes a #graphene_matrix_t compatible with #graphene_frustum_t.

    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

    • zNear: number

      distance of the near clipping plane

    • zFar: number

      distance of the far clipping plane

    Returns Graphene.Matrix

  • Initializes a #graphene_matrix_t 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: Graphene.Vec3

      the vector describing the position to look from

    • center: Graphene.Vec3

      the vector describing the position to look at

    • up: Graphene.Vec3

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

    Returns Graphene.Matrix

  • initOrtho(left: number, right: number, top: number, bottom: number, zNear: number, zFar: number): Graphene.Matrix
  • Initializes a #graphene_matrix_t 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

    • zNear: number

      the distance of the near clipping plane

    • zFar: number

      the distance of the far clipping plane

    Returns Graphene.Matrix

  • initPerspective(fovy: number, aspect: number, zNear: number, zFar: number): Graphene.Matrix
  • Initializes a #graphene_matrix_t with a perspective projection.

    Parameters

    • fovy: number

      the field of view angle, in degrees

    • aspect: number

      the aspect value

    • zNear: number

      the near Z plane

    • zFar: number

      the far Z plane

    Returns Graphene.Matrix

  • Initializes m to represent a rotation of angle degrees on the axis represented by the axis vector.

    Parameters

    • angle: number

      the rotation angle, in degrees

    • axis: Graphene.Vec3

      the axis vector as a #graphene_vec3_t

    Returns Graphene.Matrix

  • Initializes a #graphene_matrix_t with the given scaling factors.

    Parameters

    • x: number

      the scale factor on the X axis

    • y: number

      the scale factor on the Y axis

    • z: number

      the scale factor on the Z axis

    Returns Graphene.Matrix

  • Initializes a #graphene_matrix_t with a skew transformation with the given factors.

    Parameters

    • xSkew: number

      skew factor, in radians, on the X axis

    • ySkew: number

      skew factor, in radians, on the Y axis

    Returns Graphene.Matrix

  • Linearly interpolates the two given #graphene_matrix_t by interpolating the decomposed transformations separately.

    If either matrix cannot be reduced to their transformations then the interpolation cannot be performed, and this function will return an identity matrix.

    Parameters

    • b: Graphene.Matrix

      a #graphene_matrix_t

    • factor: number

      the linear interpolation factor

    Returns Graphene.Matrix

  • is2d(): boolean
  • Checks whether the given #graphene_matrix_t is compatible with an a 2D affine transformation matrix.

    Returns boolean

  • isBackfaceVisible(): boolean
  • Checks whether a #graphene_matrix_t has a visible back face.

    Returns boolean

  • isIdentity(): boolean
  • Checks whether the given #graphene_matrix_t is the identity matrix.

    Returns boolean

  • isSingular(): boolean
  • Multiplies two #graphene_matrix_t.

    Matrix multiplication is not commutative in general; the order of the factors matters. The product of this multiplication is (a × b)

    Parameters

    Returns Graphene.Matrix

  • Compares the two given #graphene_matrix_t matrices and checks whether their values are within the given epsilon of each other.

    Parameters

    • b: Graphene.Matrix

      a #graphene_matrix_t

    • epsilon: number

      the threshold between the two matrices

    Returns boolean

  • print(): void
  • 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

  • Projects all corners of a #graphene_rect_t using the given matrix.

    See also: graphene_matrix_project_point()

    Parameters

    Returns Quad

  • Projects a #graphene_rect_t using the given matrix.

    The resulting rectangle is the axis aligned bounding rectangle capable of fully containing the projected rectangle.

    Parameters

    Returns Graphene.Rect

  • 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: Graphene.Vec3

      the rotation axis, as a #graphene_vec3_t

    Returns void

  • Adds a rotation transformation to m, using the given #graphene_euler_t.

    Parameters

    Returns void

  • Adds a rotation transformation to m, using the given #graphene_quaternion_t.

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

    Parameters

    Returns void

  • rotateX(angle: number): 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

  • rotateY(angle: number): 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

  • rotateZ(angle: number): 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

  • scale(factorX: number, factorY: number, factorZ: number): 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

    • factorX: number

      scaling factor on the X axis

    • factorY: number

      scaling factor on the Y axis

    • factorZ: number

      scaling factor on the Z axis

    Returns void

  • skewXy(factor: number): void
  • Adds a skew of factor on the X and Y axis to the given matrix.

    Parameters

    • factor: number

      skew factor

    Returns void

  • skewXz(factor: number): void
  • Adds a skew of factor on the X and Z axis to the given matrix.

    Parameters

    • factor: number

      skew factor

    Returns void

  • skewYz(factor: number): void
  • Adds a skew of factor on the Y and Z axis to the given matrix.

    Parameters

    • factor: number

      skew factor

    Returns void

  • to2d(): [boolean, number, number, number, number, number, number]
  • Converts a #graphene_matrix_t 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_t
    and an affine matrix type from other libraries.

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

  • toFloat(): number[]
  • Converts a #graphene_matrix_t to an array of floating point values.

    Returns number[]

  • Transforms each corner of a #graphene_rect_t using the given matrix m.

    The result is the axis aligned bounding rectangle containing the coplanar quadrilateral.

    See also: graphene_matrix_transform_point()

    Parameters

    Returns Graphene.Rect

  • Transforms the vertices of a #graphene_box_t using the given matrix m.

    The result is the axis aligned bounding box containing the transformed vertices.

    Parameters

    Returns Graphene.Box

  • Transforms the given #graphene_point_t using the matrix m.

    Unlike graphene_matrix_transform_vec3(), this function will take into account the fourth row vector of the #graphene_matrix_t when computing the dot product of each row vector of the matrix.

    See also: graphene_simd4x4f_point3_mul()

    Parameters

    Returns Graphene.Point

  • Transforms the given #graphene_point3d_t using the matrix m.

    Unlike graphene_matrix_transform_vec3(), this function will take into account the fourth row vector of the #graphene_matrix_t when computing the dot product of each row vector of the matrix.

    See also: graphene_simd4x4f_point3_mul()

    Parameters

    Returns Point3D

  • Transforms each corner of a #graphene_rect_t using the given matrix m.

    The result is a coplanar quadrilateral.

    See also: graphene_matrix_transform_point()

    Parameters

    Returns Quad

  • Transforms a #graphene_sphere_t using the given matrix m. The result is the bounding sphere containing the transformed sphere.

    Parameters

    • s: Sphere

      a #graphene_sphere_t

    Returns Sphere

  • Transforms the given #graphene_vec3_t using the matrix m.

    This function will multiply the X, Y, and Z row vectors of the matrix m with the corresponding components of the vector v. The W row vector will be ignored.

    See also: graphene_simd4x4f_vec3_mul()

    Parameters

    Returns Graphene.Vec3

  • Transforms the given #graphene_vec4_t using the matrix m.

    See also: graphene_simd4x4f_vec4_mul()

    Parameters

    • v: Vec4

      a #graphene_vec4_t

    Returns Vec4

  • Adds a translation transformation to m using the coordinates of the given #graphene_point3d_t.

    This is the equivalent of calling graphene_matrix_init_translate() and then multiplying m with the translation matrix.

    Parameters

    • pos: Point3D

      a #graphene_point3d_t

    Returns void

  • Unprojects the given point using the projection matrix and a modelview matrix.

    Parameters

    • modelview: Graphene.Matrix

      a #graphene_matrix_t for the modelview matrix; this is the inverse of the modelview used when projecting the point

    • point: Point3D

      a #graphene_point3d_t with the coordinates of the point

    Returns Point3D

  • Undoes the transformation on the corners of a #graphene_rect_t using the given matrix, within the given axis aligned rectangular bounds.

    Parameters

    Returns Graphene.Rect

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method