30#include <Eigen/Geometry>
38 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
63 for (
int i = 0; i < 3; i++) omega[i] = update[i];
66 for (
int i = 0; i < 3; i++) upsilon[i] = update[i + 3];
68 double sigma = update[6];
69 double theta = omega.norm();
77 double eps =
cst(0.00001);
79 if (fabs(sigma) < eps) {
89 double theta2 = theta * theta;
90 A = (1 - std::cos(theta)) / (theta2);
91 B = (theta - std::sin(theta)) / (theta2 * theta);
92 R = I + std::sin(theta) / theta * Omega +
93 (1 - std::cos(theta)) / (theta * theta) * Omega2;
98 double sigma2 = sigma * sigma;
99 A = ((sigma - 1) *
s + 1) / sigma2;
100 B = ((
cst(0.5) * sigma2 - sigma + 1) *
s - 1) /
109 R = I + std::sin(theta) / theta * Omega +
110 (1 - std::cos(theta)) / (theta * theta) * Omega2;
111 double a =
s * std::sin(theta);
112 double b =
s * std::cos(theta);
113 double theta2 = theta * theta;
114 double sigma2 = sigma * sigma;
115 double c = theta2 + sigma2;
116 A = (a * sigma + (1 - b) * theta) / (theta * c);
117 B = (C - ((b - 1) * sigma + a * theta) / (c)) * 1 / (theta2);
122 Matrix3 W = A * Omega + B * Omega2 + C * I;
130 double sigma = std::log(
s);
136 double d =
cst(0.5) * (R(0, 0) + R(1, 1) + R(2, 2) - 1);
140 double eps =
cst(0.00001);
141 Matrix3 I = Matrix3::Identity();
144 if (fabs(sigma) < eps) {
152 double theta = std::acos(d);
153 double theta2 = theta * theta;
154 omega = theta / (2 * std::sqrt(1 - d * d)) *
deltaR(R);
156 A = (1 - std::cos(theta)) / (theta2);
157 B = (theta - std::sin(theta)) / (theta2 * theta);
162 double sigma2 = sigma * sigma;
165 A = ((sigma - 1) *
s + 1) / (sigma2);
166 B = ((
cst(0.5) * sigma2 - sigma + 1) *
s - 1) /
175 double theta = std::acos(d);
176 omega = theta / (2 * std::sqrt(1 - d * d)) *
deltaR(R);
178 double theta2 = theta * theta;
179 double a =
s * std::sin(theta);
180 double b =
s * std::cos(theta);
181 double c = theta2 + sigma * sigma;
182 A = (a * sigma + (1 - b) * theta) / (theta * c);
183 B = (C - ((b - 1) * sigma + a * theta) / (c)) * 1 / (theta2);
187 Matrix3 W = A * Omega + B * Omega * Omega + C * I;
189 upsilon = W.lu().solve(
t);
191 for (
int i = 0; i < 3; i++) res[i] = omega[i];
193 for (
int i = 0; i < 3; i++) res[i + 3] = upsilon[i];
201 return Sim3(
r.conjugate(),
r.conjugate() * ((-1 /
s) *
t), 1 /
s);
207 return r.coeffs()[i];
218 return r.coeffs()[i];
229 ret.
t =
s * (
r * other.
t) +
t;
235 Sim3 ret = (*this) * other;
253 inline const double&
scale()
const {
return s; }
259 out_str << sim3.
rotation().coeffs() << std::endl;
261 out_str << sim3.
scale() << std::endl;
some general case utility functions
G2O_TYPES_SLAM3D_API Vector3 deltaR(const Matrix3 &R)
G2O_TYPES_SLAM3D_API Matrix3 skew(const Vector3 &v)
constexpr double cst(long double v)
std::ostream & operator<<(std::ostream &os, const G2OBatchStatistics &st)
Eigen::Quaternion< double > Quaternion
Sim3(const Matrix3 &R, const Vector3 &t, double s)
double operator[](int i) const
Vector3 map(const Vector3 &xyz) const
const Quaternion & rotation() const
Sim3(const Quaternion &r, const Vector3 &t, double s)
Sim3 & operator*=(const Sim3 &other)
Sim3 operator*(const Sim3 &other) const
double & operator[](int i)
Sim3(const Vector7 &update)
const Vector3 & translation() const
const double & scale() const