2020-05-04 04:40:13 -07:00
|
|
|
#include "openGJK/openGJK.h"
|
|
|
|
#include <pybind11/eigen.h>
|
|
|
|
#include <pybind11/pybind11.h>
|
|
|
|
namespace py = pybind11;
|
|
|
|
|
2022-07-09 14:10:45 -07:00
|
|
|
PYBIND11_MODULE(opengjkc, m) {
|
2020-05-04 04:40:13 -07:00
|
|
|
m.def("gjk",
|
2022-07-09 14:10:45 -07:00
|
|
|
[](Eigen::Array<double, Eigen::Dynamic, 3, Eigen::RowMajor> &arr1,
|
|
|
|
Eigen::Array<double, Eigen::Dynamic, 3, Eigen::RowMajor> &arr2)
|
2020-05-04 04:40:13 -07:00
|
|
|
-> double {
|
|
|
|
struct simplex s;
|
|
|
|
struct bd bd1;
|
|
|
|
struct bd bd2;
|
|
|
|
bd1.numpoints = arr1.rows();
|
2022-07-09 14:10:45 -07:00
|
|
|
std::vector<double *> arr1_rows(arr1.rows());
|
2020-05-04 04:40:13 -07:00
|
|
|
for (int i = 0; i < arr1.rows(); ++i)
|
|
|
|
arr1_rows[i] = arr1.row(i).data();
|
|
|
|
bd1.coord = arr1_rows.data();
|
|
|
|
|
|
|
|
bd2.numpoints = arr2.rows();
|
2022-07-09 14:10:45 -07:00
|
|
|
std::vector<double *> arr2_rows(arr2.rows());
|
2020-05-04 04:40:13 -07:00
|
|
|
for (int i = 0; i < arr2.rows(); ++i)
|
|
|
|
arr2_rows[i] = arr2.row(i).data();
|
|
|
|
bd2.coord = arr2_rows.data();
|
|
|
|
|
|
|
|
double a = gjk(bd1, bd2, &s);
|
|
|
|
|
|
|
|
return a;
|
|
|
|
});
|
|
|
|
}
|