4x4 Matrices in floating point

Data Structures | Typedefs | Functions
4x4 Matrices in floating point
Eina » Data Types » Matrix

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
EINA_API Eina_Matrix_Type | eina_matrix4_type_get (const Eina_Matrix4 *m)
| Returns the type of the given floating point matrix. More...
EINA_API 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...
EINA_API 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...
EINA_API double | eina_matrix4_determinant (const Eina_Matrix4 *m)
| Calculates the determinant of the given matrix. More...
EINA_API Eina_Bool | eina_matrix4_normalized (Eina_Matrix4 *out, const Eina_Matrix4 *in)
| Normalizes the given matrix. More...
EINA_API Eina_Bool | eina_matrix4_inverse (Eina_Matrix4 *out, const Eina_Matrix4 *in)
| Computes the inverse of the given matrix. More...
EINA_API void | eina_matrix4_transpose (Eina_Matrix4 *out, const Eina_Matrix4 *in)
| Computes the transpose of the given matrix. More...
EINA_API void | eina_matrix4_matrix3_to (Eina_Matrix3 *m3, const Eina_Matrix4 *m4)
| Converts an Eina_Matrix4 into an Eina_Matrix3. More...
EINA_API void | eina_matrix4_identity (Eina_Matrix4 *out)
| Sets the given matrix to identity. More...
EINA_API void | eina_matrix4_multiply_copy (Eina_Matrix4 *out, const Eina_Matrix4 *mat_a, const Eina_Matrix4 *mat_b)
| Multiplies two matrix. More...
EINA_API void | eina_matrix4_array_set (Eina_Matrix4 *m, const double *v)
| Sets matrix values using an array. More...
EINA_API void | eina_matrix4_copy (Eina_Matrix4 *dst, const Eina_Matrix4 *src)
| Copies matrix. More...
EINA_API void | eina_matrix4_multiply (Eina_Matrix4 *out, const Eina_Matrix4 *mat_a, const Eina_Matrix4 *mat_b)
| Multiplies two matrices with check. More...
EINA_API void | eina_matrix4_ortho_set (Eina_Matrix4 *m, double left, double right, double bottom, double top, double dnear, double dfar)
| Sets orthogonality matrix. More...
EINA_API 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...
EINA_API void | eina_matrix4_translate (Eina_Matrix4 *t, double tx, double ty, double tz)
| Sets the matrix values for a translation operation. More...
EINA_API void | eina_matrix4_scale (Eina_Matrix4 *t, double sx, double sy, double sz)
| Sets the matrix values for a scaling operation. More...
EINA_API 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()

EINA_API Eina_Matrix_Type eina_matrix4_type_get | ( | const Eina_Matrix4 * | m | ) |

Returns the type of the given floating point matrix.

Parameters

  [in] | m | The 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()

EINA_API 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] | m | The floating point matrix.
  [in] | xx | The first coefficient value.
  [in] | xy | The second coefficient value.
  [in] | xz | The third coefficient value.
  [in] | xw | The fourth coefficient value.
  [in] | yx | The fifth coefficient value.
  [in] | yy | The sixth coefficient value.
  [in] | yz | The seventh coefficient value.
  [in] | yw | The eighth coefficient value.
  [in] | zx | The ninth coefficient value.
  [in] | zy | The tenth coefficient value.
  [in] | zz | The eleventh coefficient value.
  [in] | zw | The twelfth coefficient value.
  [in] | wx | The thirteenth coefficient value.
  [in] | wy | The fourteenth coefficient value.
  [in] | wz | The fifteenth coefficient value.
  [in] | ww | The 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()

EINA_API 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] | m | The floating point matrix.
  [out] | xx | The first coefficient value.
  [out] | xy | The second coefficient value.
  [out] | xz | The third coefficient value.
  [out] | xw | The fourth coefficient value.
  [out] | yx | The fifth coefficient value.
  [out] | yy | The sixth coefficient value.
  [out] | yz | The seventh coefficient value.
  [out] | yw | The eighth coefficient value.
  [out] | zx | The ninth coefficient value.
  [out] | zy | The tenth coefficient value.
  [out] | zz | The eleventh coefficient value.
  [out] | zw | The twelfth coefficient value.
  [out] | wx | The thirteenth coefficient value.
  [out] | wy | The fourteenth coefficient value.
  [out] | wz | The fifteenth coefficient value.
  [out] | ww | The 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()

EINA_API double eina_matrix4_determinant | ( | const Eina_Matrix4 * | m | ) |

Calculates the determinant of the given matrix.

Parameters

  [in] | m | The 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()

EINA_API Eina_Bool eina_matrix4_normalized | ( | Eina_Matrix4 * | out,
|  | const Eina_Matrix4 * | in
| ) |  |

Normalizes the given matrix.

Parameters

  [out] | out | The normalized matrix.
  [in] | in | The 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()

EINA_API Eina_Bool eina_matrix4_inverse | ( | Eina_Matrix4 * | out,
|  | const Eina_Matrix4 * | in
| ) |  |

Computes the inverse of the given matrix.

Parameters

  [out] | out | The inverse matrix.
  [in] | in | The 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()

EINA_API void eina_matrix4_transpose | ( | Eina_Matrix4 * | out,
|  | const Eina_Matrix4 * | in
| ) |  |

Computes the transpose of the given matrix.

Parameters

  [out] | out | The transposed matrix.
  [in] | in | The 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()

EINA_API void eina_matrix4_matrix3_to | ( | Eina_Matrix3 * | m3,
|  | const Eina_Matrix4 * | m4
| ) |  |

Converts an Eina_Matrix4 into an Eina_Matrix3.

Parameters

  [out] | m3 | The destination Eina_Matrix3.
  [in] | m4 | The source Eina_Matrix4.

Since
  1.15

## ◆ eina_matrix4_identity()

EINA_API void eina_matrix4_identity | ( | Eina_Matrix4 * | out | ) |

Sets the given matrix to identity.

Parameters

  [out] | out | The matrix to set.

Since
  1.16

Referenced by eina_matrix4_rotate(), and eina_quaternion_matrix4_to().

## ◆ eina_matrix4_multiply_copy()

EINA_API void eina_matrix4_multiply_copy | ( | Eina_Matrix4 * | out,
|  | const Eina_Matrix4 * | mat_a,
|  | const Eina_Matrix4 * | mat_b
| ) |  |

Multiplies two matrix.

Parameters

  [out] | out | The resulting matrix.
  [in] | mat_a | The first member of the multiplication.
  [in] | mat_b | The 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()

EINA_API void eina_matrix4_array_set | ( | Eina_Matrix4 * | m,
|  | const double * | v
| ) |  |

Sets matrix values using an array.

Parameters

  [out] | m | The result matrix.
  [in] | v | The 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()

EINA_API void eina_matrix4_copy | ( | Eina_Matrix4 * | dst,
|  | const Eina_Matrix4 * | src
| ) |  |

Copies matrix.

Parameters

  [out] | dst | The matrix copy.
  [in] | src | The matrix to copy.

Since
  1.17

Referenced by eina_matrix4_multiply(), and eina_matrix4_multiply_copy().

## ◆ eina_matrix4_multiply()

EINA_API void eina_matrix4_multiply | ( | Eina_Matrix4 * | out,
|  | const Eina_Matrix4 * | mat_a,
|  | const Eina_Matrix4 * | mat_b
| ) |  |

Multiplies two matrices with check.

Parameters

  [out] | out | The resulting matrix.
  [in] | mat_a | The first member of the multiplication.
  [in] | mat_b | The 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()

EINA_API 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] | m | The resulting matrix.
  [in] | right | The right value.
  [in] | left | The left value.
  [in] | bottom | The bottom value.
  [in] | top | The top value.
  [in] | dnear | The dnear value.
  [in] | dfar | The dfar value.

Since
  1.17

## ◆ eina_matrix4_compose()

EINA_API 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_a | The first matrix. Must be non-NULL.
  [in] | mat_b | The second matrix. Must be non-NULL.
  [out] | out | The 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()

EINA_API void eina_matrix4_translate | ( | Eina_Matrix4 * | t,
|  | double | tx,
|  | double | ty,
|  | double | tz
| ) |  |

Sets the matrix values for a translation operation.

Parameters

  [out] | t | Where to store the resulting matrix.
  [in] | tx | The X coordinate translation.
  [in] | ty | The Y coordinate translation.
  [in] | tz | The Z coordinate translation.

Since
  1.24

References eina_matrix4_compose().

## ◆ eina_matrix4_scale()

EINA_API void eina_matrix4_scale | ( | Eina_Matrix4 * | t,
|  | double | sx,
|  | double | sy,
|  | double | sz
| ) |  |

Sets the matrix values for a scaling operation.

Parameters

  [out] | t | Where to store the resulting matrix.
  [in] | sx | The X coordinate scaling factor.
  [in] | sy | The Y coordinate scaling factor.
  [in] | sz | The Z coordinate scaling factor.

Since
  1.24

References eina_matrix4_compose().

## ◆ eina_matrix4_rotate()

EINA_API void eina_matrix4_rotate | ( | Eina_Matrix4 * | t,
|  | double | rad,
|  | Eina_Matrix_Axis | axis
| ) |  |

Sets the matrix values for a rotation operation.

Parameters

  [out] | t | Where to store the resulting matrix.
  [in] | rad | The number of radians to rotate.
  [in] | axis | The 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.