1#include "state_representation/MathTools.hpp"
3namespace state_representation::math_tools {
4const Eigen::Quaterniond log(
const Eigen::Quaterniond& q) {
7 q_tmp = Eigen::Quaterniond(-q_tmp.coeffs());
9 Eigen::Quaterniond log_q = Eigen::Quaterniond(0, 0, 0, 0);
10 double q_norm = q_tmp.vec().norm();
12 log_q.vec() = (q_tmp.vec() / q_norm) * acos(std::min<double>(std::max<double>(q_tmp.w(), -1), 1));
17const Eigen::Quaterniond exp(
const Eigen::Quaterniond& q,
double lambda) {
18 Eigen::Quaterniond exp_q = Eigen::Quaterniond::Identity();
19 double q_norm = q.vec().norm();
21 exp_q.w() = cos(q_norm * lambda);
22 exp_q.vec() = (q.vec() / q_norm) * sin(q_norm * lambda);
27const std::vector<double> linspace(
double start,
double end,
unsigned int number_of_points) {
29 if (number_of_points < 2) {
30 throw new std::exception();
32 int partitions = number_of_points - 1;
33 std::vector<double> pts;
35 double length = (end - start) / partitions;
38 for (
unsigned int i = 1; i < number_of_points - 1; i++) {
39 pts.push_back(start + i * length);