Data Structures | Typedefs | Functions
4x4 Matrices in floating point

Definition and operations for 4x4 matrices. More...

Data Structures

struct  _Eina_Matrix4
 
struct  Eina_Matrix4
 A 4x4 floating point matrix. More...
 

Typedefs

typedef struct _Eina_Matrix4 Eina_Matrix4
 A 4x4 floating point matrix.
 

Functions

EAPI Eina_Matrix_Type eina_matrix4_type_get (const Eina_Matrix4 *m)
 Returns the type of the given floating point matrix. More...
 
EAPI void eina_matrix4_values_set (Eina_Matrix4 *m, double xx, double xy, double xz, double xw, double yx, double yy, double yz, double yw, double zx, double zy, double zz, double zw, double wx, double wy, double wz, double ww)
 Sets the values of the coefficients of the given floating point matrix. More...
 
EAPI void eina_matrix4_values_get (const Eina_Matrix4 *m, double *xx, double *xy, double *xz, double *xw, double *yx, double *yy, double *yz, double *yw, double *zx, double *zy, double *zz, double *zw, double *wx, double *wy, double *wz, double *ww)
 Gets the values of the coefficients of the given floating point matrix. More...
 
EAPI double eina_matrix4_determinant (const Eina_Matrix4 *m)
 Calculates the determinant of the given matrix. More...
 
EAPI Eina_Bool eina_matrix4_normalized (Eina_Matrix4 *out, const Eina_Matrix4 *in)
 Normalizes the given matrix. More...
 
EAPI Eina_Bool eina_matrix4_inverse (Eina_Matrix4 *out, const Eina_Matrix4 *in)
 Computes the inverse of the given matrix. More...
 
EAPI void eina_matrix4_transpose (Eina_Matrix4 *out, const Eina_Matrix4 *in)
 Computes the transpose of the given matrix. More...
 
EAPI void eina_matrix4_matrix3_to (Eina_Matrix3 *m3, const Eina_Matrix4 *m4)
 Converts an Eina_Matrix4 into an Eina_Matrix3. More...
 
EAPI void eina_matrix4_identity (Eina_Matrix4 *out)
 Sets the given matrix to identity. More...
 
EAPI void eina_matrix4_multiply_copy (Eina_Matrix4 *out, const Eina_Matrix4 *mat_a, const Eina_Matrix4 *mat_b)
 Multiplies two matrix. More...
 
EAPI void eina_matrix4_array_set (Eina_Matrix4 *m, const double *v)
 Sets matrix values using an array. More...
 
EAPI void eina_matrix4_copy (Eina_Matrix4 *dst, const Eina_Matrix4 *src)
 Copies matrix. More...
 
EAPI void eina_matrix4_multiply (Eina_Matrix4 *out, const Eina_Matrix4 *mat_a, const Eina_Matrix4 *mat_b)
 Multiplies two matrices with check. More...
 
EAPI void eina_matrix4_ortho_set (Eina_Matrix4 *m, double left, double right, double bottom, double top, double dnear, double dfar)
 Sets orthogonality matrix. More...
 
EAPI void eina_matrix4_compose (const Eina_Matrix4 *mat_a, const Eina_Matrix4 *mat_b, Eina_Matrix4 *out)
 Sets out as the matrix multiplication (composition) of two matrices. More...
 
EAPI void eina_matrix4_translate (Eina_Matrix4 *t, double tx, double ty, double tz)
 Sets the matrix values for a translation operation. More...
 
EAPI void eina_matrix4_scale (Eina_Matrix4 *t, double sx, double sy, double sz)
 Sets the matrix values for a scaling operation. More...
 
EAPI void eina_matrix4_rotate (Eina_Matrix4 *t, double rad, Eina_Matrix_Axis axis)
 Sets the matrix values for a rotation operation. More...
 

Detailed Description

Definition and operations for 4x4 matrices.

Function Documentation

◆ eina_matrix4_type_get()

EAPI Eina_Matrix_Type eina_matrix4_type_get ( const Eina_Matrix4 m)

Returns the type of the given floating point matrix.

Parameters
[in]mThe floating point matrix.
Returns
The type of the matrix.

This function returns the type of the matrix m. No check is done on m.

Since
1.15

References EINA_DBL_EQ, EINA_MATRIX_TYPE_AFFINE, and EINA_MATRIX_TYPE_IDENTITY.

Referenced by eina_matrix4_multiply(), and eina_quaternion_transform().

◆ eina_matrix4_values_set()

EAPI void eina_matrix4_values_set ( Eina_Matrix4 m,
double  xx,
double  xy,
double  xz,
double  xw,
double  yx,
double  yy,
double  yz,
double  yw,
double  zx,
double  zy,
double  zz,
double  zw,
double  wx,
double  wy,
double  wz,
double  ww 
)

Sets the values of the coefficients of the given floating point matrix.

Parameters
[out]mThe floating point matrix.
[in]xxThe first coefficient value.
[in]xyThe second coefficient value.
[in]xzThe third coefficient value.
[in]xwThe fourth coefficient value.
[in]yxThe fifth coefficient value.
[in]yyThe sixth coefficient value.
[in]yzThe seventh coefficient value.
[in]ywThe eighth coefficient value.
[in]zxThe ninth coefficient value.
[in]zyThe tenth coefficient value.
[in]zzThe eleventh coefficient value.
[in]zwThe twelfth coefficient value.
[in]wxThe thirteenth coefficient value.
[in]wyThe fourteenth coefficient value.
[in]wzThe fifteenth coefficient value.
[in]wwThe sixteenth coefficient value.

This function sets the values of the coefficients of the matrix m. No check is done on m.

See also
eina_matrix4_values_get()
Since
1.15

◆ eina_matrix4_values_get()

EAPI void eina_matrix4_values_get ( const Eina_Matrix4 m,
double *  xx,
double *  xy,
double *  xz,
double *  xw,
double *  yx,
double *  yy,
double *  yz,
double *  yw,
double *  zx,
double *  zy,
double *  zz,
double *  zw,
double *  wx,
double *  wy,
double *  wz,
double *  ww 
)

Gets the values of the coefficients of the given floating point matrix.

Parameters
[in]mThe floating point matrix.
[out]xxThe first coefficient value.
[out]xyThe second coefficient value.
[out]xzThe third coefficient value.
[out]xwThe fourth coefficient value.
[out]yxThe fifth coefficient value.
[out]yyThe sixth coefficient value.
[out]yzThe seventh coefficient value.
[out]ywThe eighth coefficient value.
[out]zxThe ninth coefficient value.
[out]zyThe tenth coefficient value.
[out]zzThe eleventh coefficient value.
[out]zwThe twelfth coefficient value.
[out]wxThe thirteenth coefficient value.
[out]wyThe fourteenth coefficient value.
[out]wzThe fifteenth coefficient value.
[out]wwThe sixteenth coefficient value.

This function gets the values of the coefficients of the matrix m. No check is done on m.

See also
eina_matrix4_values_set()
Since
1.15

◆ eina_matrix4_determinant()

EAPI double eina_matrix4_determinant ( const Eina_Matrix4 m)

Calculates the determinant of the given matrix.

Parameters
[in]mThe matrix.
Returns
The determinant.

This function returns the determinant of the matrix m. No check is done on m.

Since
1.16

Referenced by eina_matrix4_normalized(), and eina_matrix4_quaternion_to().

◆ eina_matrix4_normalized()

EAPI Eina_Bool eina_matrix4_normalized ( Eina_Matrix4 out,
const Eina_Matrix4 in 
)

Normalizes the given matrix.

Parameters
[out]outThe normalized matrix.
[in]inThe matrix.
Returns
EINA_FALSE if matrix could not be normalized, EINA_TRUE otherwise.

This function returns the determinant of the matrix in. No check is done on in.

Since
1.16

References EINA_FALSE, eina_matrix4_determinant(), and EINA_TRUE.

◆ eina_matrix4_inverse()

EAPI Eina_Bool eina_matrix4_inverse ( Eina_Matrix4 out,
const Eina_Matrix4 in 
)

Computes the inverse of the given matrix.

Parameters
[out]outThe inverse matrix.
[in]inThe matrix.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

This function inverts the matrix in and stores the result in out. No check is done on in or out. If in cannot be inverted, then EINA_FALSE is returned.

Since
1.16

References EINA_FALSE, and EINA_TRUE.

Referenced by eina_matrix4_quaternion_to().

◆ eina_matrix4_transpose()

EAPI void eina_matrix4_transpose ( Eina_Matrix4 out,
const Eina_Matrix4 in 
)

Computes the transpose of the given matrix.

Parameters
[out]outThe transposed matrix.
[in]inThe source matrix.

This function transposes the matrix in and stores the result in out. No check is done on in or out. The transpose of a matrix essentially flips a matrix over its diagonal.

Since
1.16

Referenced by eina_matrix4_quaternion_to().

◆ eina_matrix4_matrix3_to()

EAPI void eina_matrix4_matrix3_to ( Eina_Matrix3 m3,
const Eina_Matrix4 m4 
)

Converts an Eina_Matrix4 into an Eina_Matrix3.

Parameters
[out]m3The destination Eina_Matrix3.
[in]m4The source Eina_Matrix4.
Since
1.15

◆ eina_matrix4_identity()

EAPI void eina_matrix4_identity ( Eina_Matrix4 out)

Sets the given matrix to identity.

Parameters
[out]outThe matrix to set.
Since
1.16

Referenced by eina_matrix4_rotate(), and eina_quaternion_matrix4_to().

◆ eina_matrix4_multiply_copy()

EAPI void eina_matrix4_multiply_copy ( Eina_Matrix4 out,
const Eina_Matrix4 mat_a,
const Eina_Matrix4 mat_b 
)

Multiplies two matrix.

Parameters
[out]outThe resulting matrix.
[in]mat_aThe first member of the multiplication.
[in]mat_bThe second member of the multiplication.

Safely multiplies mat_a and mat_b by checking if the out parameter points to either of them, and if so uses a temporary matrix for the intermediary calculations.

Since
1.17

References eina_matrix4_copy(), and eina_matrix4_multiply().

◆ eina_matrix4_array_set()

EAPI void eina_matrix4_array_set ( Eina_Matrix4 m,
const double *  v 
)

Sets matrix values using an array.

Parameters
[out]mThe result matrix.
[in]vThe the array[16] of values.

Uses the first 16 elements in the given C array v to set the values in the matrix m. The values will be set in the order of the elements in the Eina_Matrix4 structure.

Since
1.17

◆ eina_matrix4_copy()

EAPI void eina_matrix4_copy ( Eina_Matrix4 dst,
const Eina_Matrix4 src 
)

Copies matrix.

Parameters
[out]dstThe matrix copy.
[in]srcThe matrix to copy.
Since
1.17

Referenced by eina_matrix4_multiply(), and eina_matrix4_multiply_copy().

◆ eina_matrix4_multiply()

EAPI void eina_matrix4_multiply ( Eina_Matrix4 out,
const Eina_Matrix4 mat_a,
const Eina_Matrix4 mat_b 
)

Multiplies two matrices with check.

Parameters
[out]outThe resulting matrix.
[in]mat_aThe first member of the multiplication.
[in]mat_bThe second member of the multiplication.
Since
1.17

References eina_matrix4_compose(), eina_matrix4_copy(), eina_matrix4_type_get(), and EINA_MATRIX_TYPE_IDENTITY.

Referenced by eina_matrix4_multiply_copy(), and eina_quaternion_matrix4_to().

◆ eina_matrix4_ortho_set()

EAPI void eina_matrix4_ortho_set ( Eina_Matrix4 m,
double  left,
double  right,
double  bottom,
double  top,
double  dnear,
double  dfar 
)

Sets orthogonality matrix.

Parameters
[out]mThe resulting matrix.
[in]rightThe right value.
[in]leftThe left value.
[in]bottomThe bottom value.
[in]topThe top value.
[in]dnearThe dnear value.
[in]dfarThe dfar value.
Since
1.17

◆ eina_matrix4_compose()

EAPI void eina_matrix4_compose ( const Eina_Matrix4 mat_a,
const Eina_Matrix4 mat_b,
Eina_Matrix4 out 
)

Sets out as the matrix multiplication (composition) of two matrices.

Parameters
[in]mat_aThe first matrix. Must be non-NULL.
[in]mat_bThe second matrix. Must be non-NULL.
[out]outThe results matrix.

In matrix multiplication, AB, the resultant matrix is created from the rows of A multiplied against the columns of B and summed. This is not commutative; i.e. AB != BA, so the ordering of arguments m1 and m2 matters.

Since
1.24

Referenced by eina_matrix4_multiply(), eina_matrix4_rotate(), eina_matrix4_scale(), and eina_matrix4_translate().

◆ eina_matrix4_translate()

EAPI void eina_matrix4_translate ( Eina_Matrix4 t,
double  tx,
double  ty,
double  tz 
)

Sets the matrix values for a translation operation.

Parameters
[out]tWhere to store the resulting matrix.
[in]txThe X coordinate translation.
[in]tyThe Y coordinate translation.
[in]tzThe Z coordinate translation.
Since
1.24

References eina_matrix4_compose().

◆ eina_matrix4_scale()

EAPI void eina_matrix4_scale ( Eina_Matrix4 t,
double  sx,
double  sy,
double  sz 
)

Sets the matrix values for a scaling operation.

Parameters
[out]tWhere to store the resulting matrix.
[in]sxThe X coordinate scaling factor.
[in]syThe Y coordinate scaling factor.
[in]szThe Z coordinate scaling factor.
Since
1.24

References eina_matrix4_compose().

◆ eina_matrix4_rotate()

EAPI void eina_matrix4_rotate ( Eina_Matrix4 t,
double  rad,
Eina_Matrix_Axis  axis 
)

Sets the matrix values for a rotation operation.

Parameters
[out]tWhere to store the resulting matrix.
[in]radThe number of radians to rotate.
[in]axisThe Axis of rotation.
Since
1.24

References eina_matrix4_compose(), eina_matrix4_identity(), EINA_MATRIX_AXIS_X, EINA_MATRIX_AXIS_Y, and EINA_MATRIX_AXIS_Z.