8 #include <pybind11/numpy.h>
9 #include <pybind11/pybind11.h>
10 #include <pybind11/stl.h>
11 #include <pybind11/stl_bind.h>
18 using namespace pybind11::literals;
20 template <
typename ccGLMatrixType,
typename Inner>
23 py::class_<ccGLMatrixType>(m,
name)
33 .def_static(
"Interpolate", &ccGLMatrixType::Interpolate,
"coef"_a,
"glMat1"_a,
"glMat2"_a)
44 "FromViewDirAndUpDir",
46 {
return ccGLMatrixType::FromViewDirAndUpDir(a, b); },
49 .def(py::init(&ccGLMatrixType::FromViewDirAndUpDir), py::kw_only(),
"forward"_a,
"up"_a)
54 {
return ccGLMatrixType::FromToRotation(a, b); },
57 .def(py::init(&ccGLMatrixType::FromToRotation), py::kw_only(),
"from"_a,
"to"_a)
58 .def(
"xRotation", &ccGLMatrixType::xRotation)
59 .def(
"yRotation", &ccGLMatrixType::yRotation)
60 .def(
"zRotation", &ccGLMatrixType::zRotation)
61 .def(
"toZero", &ccGLMatrixType::toZero)
62 .def(
"toIdentity", &ccGLMatrixType::toIdentity)
63 .def(
"clearTranslation", &ccGLMatrixType::clearTranslation)
64 .def(
"getTranslationAsVec3D", &ccGLMatrixType::getTranslationAsVec3D)
65 .def(
"initFromParameters",
66 static_cast<void (ccGLMatrixType::*)(
68 &ccGLMatrixType::initFromParameters),
72 .def(
"initFromParameters",
73 static_cast<void (ccGLMatrixType::*)(Inner, Inner, Inner,
const Vector3Tpl<Inner> &)
>(
74 &ccGLMatrixType::initFromParameters),
80 .def(
"setTranslation",
82 &ccGLMatrixType::setTranslation),
84 .def(
"getColumnAsVec3D", &ccGLMatrixType::getColumnAsVec3D,
"index"_a)
87 &ccGLMatrixType::setColumn),
98 .def(py::self += py::self)
99 .def(py::self -= py::self)
100 .def(py::self *= py::self)
104 [](ccGLMatrixType &
self, ccGLMatrixType &other) -> ccGLMatrixType
105 {
return self * other; })
107 [](
const ccGLMatrixType &
self,
const std::pair<unsigned, unsigned> &item)
108 {
return self(item.first, item.second); })
110 .def(
"shiftRotationCenter", &ccGLMatrixType::shiftRotationCenter,
"vec"_a)
111 .def(
"transpose", &ccGLMatrixType::transpose)
112 .def(
"invert", &ccGLMatrixType::invert)
113 .def(
"inverse", &ccGLMatrixType::inverse)
114 .def(
"scaleRotation", &ccGLMatrixType::scaleRotation,
"coef"_a)
115 .def(
"scaleRow", &ccGLMatrixType::scaleRow,
"rowIndex"_a,
"coef"_a)
116 .def(
"scaleColumn", &ccGLMatrixType::scaleColumn,
"rowIndex"_a,
"coef"_a)
123 define_ccGLMatrixClass<ccGLMatrix, float>(m,
"ccGLMatrix");
124 define_ccGLMatrixClass<ccGLMatrixd, double>(m,
"ccGLMatrixd");
static void define_ccGLMatrixClass(py::module &m, const char *name)
void define_ccGLMatrix(py::module &m)
3D Vector (templated version)
py::array_t< T > SpanAsNumpyArray(T *data, py::array::ShapeContainer shape)