31 #include <Eigen/Geometry> 40 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
55 Sim3(
const Eigen::Quaterniond & r,
const Eigen::Vector3d & t,
double s)
61 Sim3(
const Eigen::Matrix3d & R,
const Eigen::Vector3d & t,
double s)
62 : r(
Eigen::Quaterniond(R)),t(t),s(s)
68 Sim3(
const Vector7d & update)
71 Eigen::Vector3d omega;
72 for (
int i=0; i<3; i++)
75 Eigen::Vector3d upsilon;
76 for (
int i=0; i<3; i++)
77 upsilon[i]=update[i+3];
79 double sigma = update[6];
80 double theta = omega.norm();
81 Eigen::Matrix3d Omega =
skew(omega);
83 Eigen::Matrix3d Omega2 = Omega*Omega;
97 R = (I + Omega + Omega*Omega);
101 double theta2= theta*theta;
102 A = (1-cos(theta))/(theta2);
103 B = (theta-sin(theta))/(theta2*theta);
104 R = I + sin(theta)/theta *Omega + (1-cos(theta))/(theta*theta)*Omega2;
112 double sigma2= sigma*sigma;
113 A = ((sigma-1)*s+1)/sigma2;
114 B= ((0.5*sigma2-sigma+1)*s)/(sigma2*sigma);
115 R = (I + Omega + Omega2);
119 R = I + sin(theta)/theta *Omega + (1-cos(theta))/(theta*theta)*Omega2;
120 double a=s*sin(theta);
121 double b=s*cos(theta);
122 double theta2= theta*theta;
123 double sigma2= sigma*sigma;
124 double c=theta2+sigma2;
125 A = (a*sigma+ (1-b)*theta)/(theta*c);
126 B = (C-((b-1)*sigma+a*theta)/(c))*1./(theta2);
130 r = Eigen::Quaterniond(R);
134 Eigen::Matrix3d W = A*Omega + B*Omega2 + C*I;
138 Eigen::Vector3d
map (
const Eigen::Vector3d& xyz)
const {
139 return s*(r*xyz) + t;
145 double sigma = std::log(s);
147 Eigen::Vector3d omega;
148 Eigen::Vector3d upsilon;
150 Eigen::Matrix3d R = r.toRotationMatrix();
151 double d = 0.5*(R(0,0)+R(1,1)+R(2,2)-1);
153 Eigen::Matrix3d Omega;
155 double eps = 0.00001;
156 Eigen::Matrix3d I = Eigen::Matrix3d::Identity();
171 double theta = acos(d);
172 double theta2 = theta*theta;
173 omega = theta/(2*sqrt(1-d*d))*
deltaR(R);
175 A = (1-cos(theta))/(theta2);
176 B = (theta-sin(theta))/(theta2*theta);
184 double sigma2 = sigma*sigma;
187 A = ((sigma-1)*s+1)/(sigma2);
188 B = ((0.5*sigma2-sigma+1)*s)/(sigma2*sigma);
192 double theta = acos(d);
193 omega = theta/(2*sqrt(1-d*d))*
deltaR(R);
195 double theta2 = theta*theta;
196 double a=s*sin(theta);
197 double b=s*cos(theta);
198 double c=theta2 + sigma*sigma;
199 A = (a*sigma+ (1-b)*theta)/(theta*c);
200 B = (C-((b-1)*sigma+a*theta)/(c))*1./(theta2);
204 Eigen::Matrix3d W = A*Omega + B*Omega*Omega + C*I;
206 upsilon = W.lu().solve(t);
208 for (
int i=0; i<3; i++)
211 for (
int i=0; i<3; i++)
212 res[i+3] = upsilon[i];
222 return Sim3(r.conjugate(), r.conjugate()*((-1./
s)*t), 1./
s);
230 return r.coeffs()[i];
243 return r.coeffs()[i];
255 ret.
t=s*(r*other.
t)+t;
261 Sim3 ret=(*this)*other;
275 inline const Eigen::Quaterniond&
rotation()
const {
return r;}
279 inline const double&
scale()
const {
return s;}
288 out_str << sim3.
rotation().coeffs() << std::endl;
290 out_str << sim3.
scale() << std::endl;
Sim3(const Eigen::Quaterniond &r, const Eigen::Vector3d &t, double s)
Sim3 operator*(const Sim3 &other) const
Eigen::Matrix< double, 7, 1 > Vector7d
Eigen::Quaterniond & rotation()
Eigen::Vector3d map(const Eigen::Vector3d &xyz) const
double operator[](int i) const
Sim3 & operator*=(const Sim3 &other)
double & operator[](int i)
std::ostream & operator<<(std::ostream &os, const G2OBatchStatistics &st)
Sim3(const Eigen::Matrix3d &R, const Eigen::Vector3d &t, double s)
Sim3(const Vector7d &update)
const double & scale() const
G2O_TYPES_SLAM3D_API Vector3D deltaR(const Matrix3D &R)
Eigen::Vector3d & translation()
const Eigen::Vector3d & translation() const
const Eigen::Quaterniond & rotation() const
G2O_TYPES_SLAM3D_API Matrix3D skew(const Vector3D &v)
Eigen::Matrix< double, 7, 7 > Matrix7d