1#include "state_representation/MathTools.hpp"
3namespace state_representation::math_tools {
4const Eigen::Quaterniond log(
const Eigen::Quaterniond& q) {
5 Eigen::Quaterniond log_q = Eigen::Quaterniond(0, 0, 0, 0);
6 double q_norm = q.vec().norm();
7 if (q_norm > 1e-4) { log_q.vec() = (q.vec() / q_norm) * acos(std::min<double>(std::max<double>(q.w(), -1), 1)); }
11const Eigen::Quaterniond exp(
const Eigen::Quaterniond& q,
double lambda) {
12 Eigen::Quaterniond exp_q = Eigen::Quaterniond::Identity();
13 double q_norm = q.vec().norm();
15 exp_q.w() = cos(q_norm * lambda);
16 exp_q.vec() = (q.vec() / q_norm) * sin(q_norm * lambda);
21const std::vector<double> linspace(
double start,
double end,
unsigned int number_of_points) {
23 if (number_of_points < 2) {
24 throw new std::exception();
26 int partitions = number_of_points - 1;
27 std::vector<double> pts;
29 double length = (end - start) / partitions;
32 for (
unsigned int i = 1; i < number_of_points - 1; i++) {
33 pts.push_back(start + i * length);