From 7d032d02c9ea45fa605eb222871fb9d39e87080d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 26 Feb 2019 11:04:47 +0100 Subject: [PATCH] Initial documentation for python interface --- .../.python-scripting.docu.kate-swp | Bin 123 -> 0 bytes .../DeveloperHelpSources/Interfaces.docu | 8 ++++ .../DeveloperHelpSources/mainpage.docu | 2 +- .../python-scripting.docu | 14 +++++- PythonInterpreter/PythonTypeConversions.hh | 45 ++++++++++++++++-- 5 files changed, 61 insertions(+), 8 deletions(-) delete mode 100644 Documentation/DeveloperHelpSources/.python-scripting.docu.kate-swp diff --git a/Documentation/DeveloperHelpSources/.python-scripting.docu.kate-swp b/Documentation/DeveloperHelpSources/.python-scripting.docu.kate-swp deleted file mode 100644 index 65acf55b70fbf351a856cb73867296be20871f9a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 123 zcmZQzU=Z?7EJ;-eE>A2_aLdd|RWQ;sU|?VniP~~u`hWe8VFr(9Jx`uh9r)m struct type_caster { public: @@ -192,7 +208,24 @@ namespace pybind11 { namespace detail { }; }} // namespace pybind11::detail - +/** \page python_scripting_matrix4x4_type Matrix4x4 data type used for python scripting + * + * The matrix type Matrix4x4 is mapped to python to handle matrix operations. + * + * The integrated conversion can map the C++ Matrix4x4 type to and from a tuple, a list or a numpy array. + * The preferred choice is the numpy array. Tuple and list have to contain 16 elements. A numpy array + * has to have a dimension of 2, with 4x4 elements. All data is assumed to be given column major. Therefore + * the first for elements define the first column and so on. + * + * Creating a matrix in python is the done like in the following example: + * \code + * import numpy as np + * + * matr = np.array( [[1.0,0.0,0.0,0.0],[0.0,1.0,0.0,0.0],[0.0,0.0,1.0,0.0],[0.0,0.0,0.0,1.0]]) + * \endcode + * + * The conversion from C++ to python will always create a numpy array on the python side. + */ namespace pybind11 { namespace detail { template <> struct type_caster { public: @@ -235,7 +268,8 @@ namespace pybind11 { namespace detail { PyFloat_AsDouble(PyList_GetItem(source,11)), PyFloat_AsDouble(PyList_GetItem(source,12)), PyFloat_AsDouble(PyList_GetItem(source,13)), - PyFloat_AsDouble(PyList_GetItem(source,14))}; + PyFloat_AsDouble(PyList_GetItem(source,14)), + PyFloat_AsDouble(PyList_GetItem(source,15))}; /* Now convert into a C++ Matrix4x4 */ value = Matrix4x4(convert); @@ -257,11 +291,12 @@ namespace pybind11 { namespace detail { PyFloat_AsDouble(PyTuple_GetItem(source,7)), PyFloat_AsDouble(PyTuple_GetItem(source,8)), PyFloat_AsDouble(PyTuple_GetItem(source,9)), - PyFloat_AsDouble(PyTuple_GetItem(source,0)), + PyFloat_AsDouble(PyTuple_GetItem(source,10)), PyFloat_AsDouble(PyTuple_GetItem(source,11)), PyFloat_AsDouble(PyTuple_GetItem(source,12)), PyFloat_AsDouble(PyTuple_GetItem(source,13)), - PyFloat_AsDouble(PyTuple_GetItem(source,14)) }; + PyFloat_AsDouble(PyTuple_GetItem(source,14)), + PyFloat_AsDouble(PyTuple_GetItem(source,15))}; /* Now convert into a C++ Matrix4x4 */ value = Matrix4x4(convert); -- GitLab