2 #define PL_SAFE_ARG_MACROS
4 #include <Eigen/Geometry>
7 void eigen2pl(
const Eigen::Quaterniond &q, term_t &out) {
16 void eigen2pl(
const Eigen::Vector3d &v, term_t &out) {
24 void eigen2pl(
const Eigen::Matrix4d &m, term_t &out) {
26 for (
int i = 0; i < 4; ++i) {
27 for (
int j = 0; j < 4; ++j) {
34 void pl2eigen(term_t &arg, Eigen::Quaterniond &q) {
47 void pl2eigen(term_t &arg, Eigen::Vector3d &v) {
58 void pl2eigen(term_t &arg, Eigen::Matrix4d &m) {
61 for (
int i = 0; i < 4; ++i) {
62 for (
int j = 0; j < 4; ++j) {
89 Eigen::Quaterniond q1, q2;
97 foreign_t
quaternion_diff(term_t t_Quaternion1, term_t t_Quaternion2, term_t t_Diff) {
98 Eigen::Quaterniond q1, q2;
101 eigen2pl(q1.inverse() * q2, t_Diff);
106 foreign_t
quaternion_slerp(term_t t_Quaternion1, term_t t_Quaternion2, term_t t_Factor, term_t t_Interpolated) {
107 Eigen::Quaterniond q1, q2;
111 if (!PL_get_float(t_Factor, &factor))
return FALSE;
112 Eigen::Quaterniond q = q1.slerp(factor, q2);
119 Eigen::Quaterniond q;
123 Eigen::Matrix4d m = Eigen::Matrix4d::Identity();
125 m.block(0, 0, 3, 3) = q.toRotationMatrix();
127 m.block(0, 3, 3, 1) = v;
136 Eigen::Matrix3d m3 = m4.block(0, 0, 3, 3);
137 Eigen::Quaterniond q(m3);
146 Eigen::Vector3d v = m.block<3, 1>(0, 3, 3, 1);
161 {
nullptr, 0,
nullptr, 0}
void pl2eigen(term_t &arg, Eigen::Quaterniond &q)
foreign_t quaternion_transform(term_t t_Quaternion, term_t t_Vector, term_t t_Transformed)
foreign_t matrix_translation(term_t t_Matrix, term_t t_Translation)
foreign_t matrix_quaternion(term_t t_Matrix, term_t t_Quaternion)
foreign_t quaternion_inverse(term_t t_Quaternion, term_t t_Inverse)
foreign_t quaternion_diff(term_t t_Quaternion1, term_t t_Quaternion2, term_t t_Diff)
void eigen2pl(const Eigen::Quaterniond &q, term_t &out)
foreign_t quaternion_multiply(term_t t_Quaternion1, term_t t_Quaternion2, term_t t_Multiplied)
foreign_t quaternion_matrix(term_t t_Quaternion, term_t t_Translation, term_t t_Matrix)
foreign_t quaternion_slerp(term_t t_Quaternion1, term_t t_Quaternion2, term_t t_Factor, term_t t_Interpolated)
PL_extension PL_extension_algebra[]