From 190ad3402800a3f166392138013cd3c7862de6c5 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sun, 10 May 2020 10:15:31 +0200 Subject: [PATCH] matrix4 --- src/matrix4.cpp | 101 ++++++++++++++++++++++++------------------------ src/matrix4.h | 12 ++---- 2 files changed, 55 insertions(+), 58 deletions(-) diff --git a/src/matrix4.cpp b/src/matrix4.cpp index 2861a0c..67d58ed 100644 --- a/src/matrix4.cpp +++ b/src/matrix4.cpp @@ -23,55 +23,56 @@ #include #include "matrix4.h" -extern "C" { - - SCM - scm_from_matrix4 (irr::core::matrix4 cmatrix) - { - return scm_list_4 (scm_list_4 (scm_from_double (cmatrix[0]), - scm_from_double (cmatrix[1]), - scm_from_double (cmatrix[2]), - scm_from_double (cmatrix[3])), - scm_list_4 (scm_from_double (cmatrix[4]), - scm_from_double (cmatrix[5]), - scm_from_double (cmatrix[6]), - scm_from_double (cmatrix[7])), - scm_list_4 (scm_from_double (cmatrix[8]), - scm_from_double (cmatrix[9]), - scm_from_double (cmatrix[10]), - scm_from_double (cmatrix[11])), - scm_list_4 (scm_from_double (cmatrix[12]), - scm_from_double (cmatrix[13]), - scm_from_double (cmatrix[14]), - scm_from_double (cmatrix[15]))); - } - - irr::core::matrix4 - scm_to_matrix4 (SCM matrix) - { - irr::core::matrix4 cmatrix; - - cmatrix[0] = scm_to_double (scm_car (scm_car (matrix))); - cmatrix[1] = scm_to_double (scm_cadr (scm_car (matrix))); - cmatrix[2] = scm_to_double (scm_caddr (scm_car (matrix))); - cmatrix[3] = scm_to_double (scm_cadddr (scm_car (matrix))); - - cmatrix[4] = scm_to_double (scm_car (scm_cadr (matrix))); - cmatrix[5] = scm_to_double (scm_cadr (scm_cadr (matrix))); - cmatrix[6] = scm_to_double (scm_caddr (scm_cadr (matrix))); - cmatrix[7] = scm_to_double (scm_cadddr (scm_cadr (matrix))); - - cmatrix[8] = scm_to_double (scm_car (scm_caddr (matrix))); - cmatrix[9] = scm_to_double (scm_cadr (scm_caddr (matrix))); - cmatrix[10] = scm_to_double (scm_caddr (scm_caddr (matrix))); - cmatrix[11] = scm_to_double (scm_cadddr (scm_caddr (matrix))); - - cmatrix[12] = scm_to_double (scm_car (scm_cadddr (matrix))); - cmatrix[13] = scm_to_double (scm_cadr (scm_cadddr (matrix))); - cmatrix[14] = scm_to_double (scm_caddr (scm_cadddr (matrix))); - cmatrix[15] = scm_to_double (scm_cadddr (scm_cadddr (matrix))); - - return cmatrix; - } +using namespace irr; + + +SCM +scm_from_matrix4 (core::matrix4 cmatrix) +{ + return scm_list_4 (scm_list_4 (scm_from_double (cmatrix[0]), + scm_from_double (cmatrix[1]), + scm_from_double (cmatrix[2]), + scm_from_double (cmatrix[3])), + scm_list_4 (scm_from_double (cmatrix[4]), + scm_from_double (cmatrix[5]), + scm_from_double (cmatrix[6]), + scm_from_double (cmatrix[7])), + scm_list_4 (scm_from_double (cmatrix[8]), + scm_from_double (cmatrix[9]), + scm_from_double (cmatrix[10]), + scm_from_double (cmatrix[11])), + scm_list_4 (scm_from_double (cmatrix[12]), + scm_from_double (cmatrix[13]), + scm_from_double (cmatrix[14]), + scm_from_double (cmatrix[15]))); +} + + +core::matrix4 +scm_to_matrix4 (SCM matrix) +{ + core::matrix4 cmatrix; + + cmatrix[0] = scm_to_double (scm_car (scm_car (matrix))); + cmatrix[1] = scm_to_double (scm_cadr (scm_car (matrix))); + cmatrix[2] = scm_to_double (scm_caddr (scm_car (matrix))); + cmatrix[3] = scm_to_double (scm_cadddr (scm_car (matrix))); + + cmatrix[4] = scm_to_double (scm_car (scm_cadr (matrix))); + cmatrix[5] = scm_to_double (scm_cadr (scm_cadr (matrix))); + cmatrix[6] = scm_to_double (scm_caddr (scm_cadr (matrix))); + cmatrix[7] = scm_to_double (scm_cadddr (scm_cadr (matrix))); + + cmatrix[8] = scm_to_double (scm_car (scm_caddr (matrix))); + cmatrix[9] = scm_to_double (scm_cadr (scm_caddr (matrix))); + cmatrix[10] = scm_to_double (scm_caddr (scm_caddr (matrix))); + cmatrix[11] = scm_to_double (scm_cadddr (scm_caddr (matrix))); + + cmatrix[12] = scm_to_double (scm_car (scm_cadddr (matrix))); + cmatrix[13] = scm_to_double (scm_cadr (scm_cadddr (matrix))); + cmatrix[14] = scm_to_double (scm_caddr (scm_cadddr (matrix))); + cmatrix[15] = scm_to_double (scm_cadddr (scm_cadddr (matrix))); + + return cmatrix; } diff --git a/src/matrix4.h b/src/matrix4.h index 2653051..dd3b030 100644 --- a/src/matrix4.h +++ b/src/matrix4.h @@ -25,14 +25,10 @@ #include #include -extern "C" { +SCM +scm_from_matrix4 (irr::core::matrix4 cmatrix); - SCM - scm_from_matrix4 (irr::core::matrix4 cmatrix); - - irr::core::matrix4 - scm_to_matrix4 (SCM matrix); - -} +irr::core::matrix4 +scm_to_matrix4 (SCM matrix); #endif -- 2.39.5