summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-06-24 16:56:26 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-08-21 16:40:31 +0200
commit4f0f81bb30f33b8e5f72008c2cf2ef438d5283e6 (patch)
treeaf3212554d17d81c6a345a11bed7a78dd18d1ddf
parentc82015d0625448160b4e0320babdacdbbd80765d (diff)
eina: add eina_matrix4_determinant.
-rw-r--r--src/lib/eina/eina_matrix.c30
-rw-r--r--src/lib/eina/eina_matrix.h13
2 files changed, 43 insertions, 0 deletions
diff --git a/src/lib/eina/eina_matrix.c b/src/lib/eina/eina_matrix.c
index 6c96893927..2e994df758 100644
--- a/src/lib/eina/eina_matrix.c
+++ b/src/lib/eina/eina_matrix.c
@@ -693,3 +693,33 @@ eina_matrix3_matrix4_to(Eina_Matrix4 *m4, const Eina_Matrix3 *m3)
693 MATRIX_WZ(m4) = 0; 693 MATRIX_WZ(m4) = 0;
694 MATRIX_WW(m4) = MATRIX_ZZ(m3); 694 MATRIX_WW(m4) = MATRIX_ZZ(m3);
695} 695}
696
697EAPI double
698eina_matrix4_determinant(const Eina_Matrix4 *m)
699{
700 return
701 MATRIX_XW(m) * MATRIX_YZ(m) * MATRIX_ZY(m) * MATRIX_WX(m)
702 - MATRIX_XZ(m) * MATRIX_YW(m) * MATRIX_ZY(m) * MATRIX_WX(m)
703 - MATRIX_XW(m) * MATRIX_YY(m) * MATRIX_ZZ(m) * MATRIX_WX(m)
704 + MATRIX_XY(m) * MATRIX_YW(m) * MATRIX_ZZ(m) * MATRIX_WX(m)
705 + MATRIX_XZ(m) * MATRIX_YY(m) * MATRIX_ZW(m) * MATRIX_WX(m)
706 - MATRIX_XY(m) * MATRIX_YZ(m) * MATRIX_ZW(m) * MATRIX_WX(m)
707 - MATRIX_XW(m) * MATRIX_YZ(m) * MATRIX_ZX(m) * MATRIX_WY(m)
708 + MATRIX_XZ(m) * MATRIX_YW(m) * MATRIX_ZX(m) * MATRIX_WY(m)
709 + MATRIX_XW(m) * MATRIX_YX(m) * MATRIX_ZZ(m) * MATRIX_WY(m)
710 - MATRIX_XX(m) * MATRIX_YW(m) * MATRIX_ZZ(m) * MATRIX_WY(m)
711 - MATRIX_XZ(m) * MATRIX_YX(m) * MATRIX_ZW(m) * MATRIX_WY(m)
712 + MATRIX_XX(m) * MATRIX_YZ(m) * MATRIX_ZW(m) * MATRIX_WY(m)
713 + MATRIX_XW(m) * MATRIX_YY(m) * MATRIX_ZX(m) * MATRIX_WZ(m)
714 - MATRIX_XY(m) * MATRIX_YW(m) * MATRIX_ZX(m) * MATRIX_WZ(m)
715 - MATRIX_XW(m) * MATRIX_YX(m) * MATRIX_ZY(m) * MATRIX_WZ(m)
716 + MATRIX_XX(m) * MATRIX_YW(m) * MATRIX_ZY(m) * MATRIX_WZ(m)
717 + MATRIX_XY(m) * MATRIX_YX(m) * MATRIX_ZW(m) * MATRIX_WZ(m)
718 - MATRIX_XX(m) * MATRIX_YY(m) * MATRIX_ZW(m) * MATRIX_WZ(m)
719 - MATRIX_XZ(m) * MATRIX_YY(m) * MATRIX_ZX(m) * MATRIX_WW(m)
720 + MATRIX_XY(m) * MATRIX_YZ(m) * MATRIX_ZX(m) * MATRIX_WW(m)
721 + MATRIX_XZ(m) * MATRIX_YX(m) * MATRIX_ZY(m) * MATRIX_WW(m)
722 - MATRIX_XX(m) * MATRIX_YZ(m) * MATRIX_ZY(m) * MATRIX_WW(m)
723 - MATRIX_XY(m) * MATRIX_YX(m) * MATRIX_ZZ(m) * MATRIX_WW(m)
724 + MATRIX_XX(m) * MATRIX_YY(m) * MATRIX_ZZ(m) * MATRIX_WW(m);
725}
diff --git a/src/lib/eina/eina_matrix.h b/src/lib/eina/eina_matrix.h
index 83fff16540..8dc7014037 100644
--- a/src/lib/eina/eina_matrix.h
+++ b/src/lib/eina/eina_matrix.h
@@ -512,6 +512,19 @@ EAPI void eina_matrix4_values_get(const Eina_Matrix4 *m,
512 double *wx, double *wy, double *wz, double *ww); 512 double *wx, double *wy, double *wz, double *ww);
513 513
514/** 514/**
515 * @brief Return the determinant of the given matrix.
516 *
517 * @param m The matrix.
518 * @return The determinant.
519 *
520 * This function returns the determinant of the matrix @p m. No check
521 * is done on @p m.
522 *
523 * @since 1.15
524 */
525EAPI double eina_matrix4_determinant(const Eina_Matrix4 *m);
526
527/**
515 * @brief Convert an Eina_Matrix4 into an Eina_Matrix3. 528 * @brief Convert an Eina_Matrix4 into an Eina_Matrix3.
516 * 529 *
517 * @param m3 The destination Eina_Matrix3. 530 * @param m3 The destination Eina_Matrix3.