g2o
Public Member Functions | Protected Attributes | List of all members
g2o::Sim3 Struct Reference

#include <sim3.h>

Public Member Functions

 Sim3 ()
 
 Sim3 (const Eigen::Quaterniond &r, const Eigen::Vector3d &t, double s)
 
 Sim3 (const Eigen::Matrix3d &R, const Eigen::Vector3d &t, double s)
 
 Sim3 (const Vector7d &update)
 
Eigen::Vector3d map (const Eigen::Vector3d &xyz) const
 
Vector7d log () const
 
Sim3 inverse () const
 
double operator[] (int i) const
 
double & operator[] (int i)
 
Sim3 operator* (const Sim3 &other) const
 
Sim3operator*= (const Sim3 &other)
 
void normalizeRotation ()
 
const Eigen::Vector3d & translation () const
 
Eigen::Vector3d & translation ()
 
const Eigen::Quaterniond & rotation () const
 
Eigen::Quaterniond & rotation ()
 
const double & scale () const
 
double & scale ()
 

Protected Attributes

Eigen::Quaterniond r
 
Eigen::Vector3d t
 
double s
 

Detailed Description

Definition at line 38 of file sim3.h.

Constructor & Destructor Documentation

g2o::Sim3::Sim3 ( )
inline

Definition at line 48 of file sim3.h.

Referenced by inverse().

49  {
50  r.setIdentity();
51  t.fill(0.);
52  s=1.;
53  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
Eigen::Quaterniond r
Definition: sim3.h:43
g2o::Sim3::Sim3 ( const Eigen::Quaterniond &  r,
const Eigen::Vector3d &  t,
double  s 
)
inline

Definition at line 55 of file sim3.h.

References normalizeRotation().

56  : r(r),t(t),s(s)
57  {
59  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
void normalizeRotation()
Definition: sim3.h:265
Eigen::Quaterniond r
Definition: sim3.h:43
g2o::Sim3::Sim3 ( const Eigen::Matrix3d &  R,
const Eigen::Vector3d &  t,
double  s 
)
inline

Definition at line 61 of file sim3.h.

References normalizeRotation().

62  : r(Eigen::Quaterniond(R)),t(t),s(s)
63  {
65  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
void normalizeRotation()
Definition: sim3.h:265
Eigen::Quaterniond r
Definition: sim3.h:43
g2o::Sim3::Sim3 ( const Vector7d update)
inline

Definition at line 68 of file sim3.h.

References g2o::skew().

69  {
70 
71  Eigen::Vector3d omega;
72  for (int i=0; i<3; i++)
73  omega[i]=update[i];
74 
75  Eigen::Vector3d upsilon;
76  for (int i=0; i<3; i++)
77  upsilon[i]=update[i+3];
78 
79  double sigma = update[6];
80  double theta = omega.norm();
81  Eigen::Matrix3d Omega = skew(omega);
82  s = std::exp(sigma);
83  Eigen::Matrix3d Omega2 = Omega*Omega;
84  Eigen::Matrix3d I;
85  I.setIdentity();
86  Eigen::Matrix3d R;
87 
88  double eps = 0.00001;
89  double A,B,C;
90  if (fabs(sigma)<eps)
91  {
92  C = 1;
93  if (theta<eps)
94  {
95  A = 1./2.;
96  B = 1./6.;
97  R = (I + Omega + Omega*Omega);
98  }
99  else
100  {
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;
105  }
106  }
107  else
108  {
109  C=(s-1)/sigma;
110  if (theta<eps)
111  {
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);
116  }
117  else
118  {
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);
127 
128  }
129  }
130  r = Eigen::Quaterniond(R);
131 
132 
133 
134  Eigen::Matrix3d W = A*Omega + B*Omega2 + C*I;
135  t = W*upsilon;
136  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
Eigen::Quaterniond r
Definition: sim3.h:43
G2O_TYPES_SLAM3D_API Matrix3D skew(const Vector3D &v)
Definition: se3_ops.h:28

Member Function Documentation

Sim3 g2o::Sim3::inverse ( ) const
inline

Definition at line 220 of file sim3.h.

References s, and Sim3().

Referenced by g2o::EdgeSim3::computeError(), and g2o::EdgeSim3::read().

221  {
222  return Sim3(r.conjugate(), r.conjugate()*((-1./s)*t), 1./s);
223  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
Sim3()
Definition: sim3.h:48
Eigen::Quaterniond r
Definition: sim3.h:43
Vector7d g2o::Sim3::log ( ) const
inline

Definition at line 142 of file sim3.h.

References g2o::deltaR(), and g2o::skew().

Referenced by g2o::EdgeSim3::computeError(), g2o::VertexSim3Expmap::write(), and g2o::EdgeSim3::write().

143  {
144  Vector7d res;
145  double sigma = std::log(s);
146 
147  Eigen::Vector3d omega;
148  Eigen::Vector3d upsilon;
149 
150  Eigen::Matrix3d R = r.toRotationMatrix();
151  double d = 0.5*(R(0,0)+R(1,1)+R(2,2)-1);
152 
153  Eigen::Matrix3d Omega;
154 
155  double eps = 0.00001;
156  Eigen::Matrix3d I = Eigen::Matrix3d::Identity();
157 
158  double A,B,C;
159  if (fabs(sigma)<eps)
160  {
161  C = 1;
162  if (d>1-eps)
163  {
164  omega=0.5*deltaR(R);
165  Omega = skew(omega);
166  A = 1./2.;
167  B = 1./6.;
168  }
169  else
170  {
171  double theta = acos(d);
172  double theta2 = theta*theta;
173  omega = theta/(2*sqrt(1-d*d))*deltaR(R);
174  Omega = skew(omega);
175  A = (1-cos(theta))/(theta2);
176  B = (theta-sin(theta))/(theta2*theta);
177  }
178  }
179  else
180  {
181  C=(s-1)/sigma;
182  if (d>1-eps)
183  {
184  double sigma2 = sigma*sigma;
185  omega=0.5*deltaR(R);
186  Omega = skew(omega);
187  A = ((sigma-1)*s+1)/(sigma2);
188  B = ((0.5*sigma2-sigma+1)*s)/(sigma2*sigma);
189  }
190  else
191  {
192  double theta = acos(d);
193  omega = theta/(2*sqrt(1-d*d))*deltaR(R);
194  Omega = skew(omega);
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);
201  }
202  }
203 
204  Eigen::Matrix3d W = A*Omega + B*Omega*Omega + C*I;
205 
206  upsilon = W.lu().solve(t);
207 
208  for (int i=0; i<3; i++)
209  res[i] = omega[i];
210 
211  for (int i=0; i<3; i++)
212  res[i+3] = upsilon[i];
213 
214  res[6] = sigma;
215 
216  return res;
217  }
Eigen::Vector3d t
Definition: sim3.h:44
Eigen::Matrix< double, 7, 1 > Vector7d
Definition: sim3.h:35
double s
Definition: sim3.h:45
Eigen::Quaterniond r
Definition: sim3.h:43
G2O_TYPES_SLAM3D_API Vector3D deltaR(const Matrix3D &R)
Definition: se3_ops.h:41
G2O_TYPES_SLAM3D_API Matrix3D skew(const Vector3D &v)
Definition: se3_ops.h:28
Eigen::Vector3d g2o::Sim3::map ( const Eigen::Vector3d &  xyz) const
inline

Definition at line 138 of file sim3.h.

Referenced by g2o::EdgeSim3ProjectXYZ::computeError().

138  {
139  return s*(r*xyz) + t;
140  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
Eigen::Quaterniond r
Definition: sim3.h:43
void g2o::Sim3::normalizeRotation ( )
inline

Definition at line 265 of file sim3.h.

Referenced by Sim3().

265  {
266  if (r.w()<0){
267  r.coeffs() *= -1;
268  }
269  r.normalize();
270  }
Eigen::Quaterniond r
Definition: sim3.h:43
Sim3 g2o::Sim3::operator* ( const Sim3 other) const
inline

Definition at line 252 of file sim3.h.

References r, s, and t.

252  {
253  Sim3 ret;
254  ret.r = r*other.r;
255  ret.t=s*(r*other.t)+t;
256  ret.s=s*other.s;
257  return ret;
258  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
Sim3()
Definition: sim3.h:48
Eigen::Quaterniond r
Definition: sim3.h:43
Sim3& g2o::Sim3::operator*= ( const Sim3 other)
inline

Definition at line 260 of file sim3.h.

260  {
261  Sim3 ret=(*this)*other;
262  *this=ret;
263  return *this;
264  }
Sim3()
Definition: sim3.h:48
double g2o::Sim3::operator[] ( int  i) const
inline

Definition at line 225 of file sim3.h.

References s.

226  {
227  assert(i<8);
228  if (i<4){
229 
230  return r.coeffs()[i];
231  }
232  if (i<7){
233  return t[i-4];
234  }
235  return s;
236  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
Eigen::Quaterniond r
Definition: sim3.h:43
double& g2o::Sim3::operator[] ( int  i)
inline

Definition at line 238 of file sim3.h.

References s.

239  {
240  assert(i<8);
241  if (i<4){
242 
243  return r.coeffs()[i];
244  }
245  if (i<7)
246  {
247  return t[i-4];
248  }
249  return s;
250  }
Eigen::Vector3d t
Definition: sim3.h:44
double s
Definition: sim3.h:45
Eigen::Quaterniond r
Definition: sim3.h:43
const Eigen::Quaterniond& g2o::Sim3::rotation ( ) const
inline

Definition at line 275 of file sim3.h.

References r.

Referenced by g2o::operator<<().

275 {return r;}
Eigen::Quaterniond r
Definition: sim3.h:43
Eigen::Quaterniond& g2o::Sim3::rotation ( )
inline

Definition at line 277 of file sim3.h.

References r.

277 {return r;}
Eigen::Quaterniond r
Definition: sim3.h:43
const double& g2o::Sim3::scale ( ) const
inline

Definition at line 279 of file sim3.h.

References s.

Referenced by g2o::operator<<().

279 {return s;}
double s
Definition: sim3.h:45
double& g2o::Sim3::scale ( )
inline

Definition at line 281 of file sim3.h.

References s.

281 {return s;}
double s
Definition: sim3.h:45
const Eigen::Vector3d& g2o::Sim3::translation ( ) const
inline

Definition at line 271 of file sim3.h.

References t.

Referenced by g2o::operator<<().

271 {return t;}
Eigen::Vector3d t
Definition: sim3.h:44
Eigen::Vector3d& g2o::Sim3::translation ( )
inline

Definition at line 273 of file sim3.h.

References t.

273 {return t;}
Eigen::Vector3d t
Definition: sim3.h:44

Member Data Documentation

Eigen::Quaterniond g2o::Sim3::r
protected

Definition at line 43 of file sim3.h.

Referenced by operator*(), and rotation().

double g2o::Sim3::s
protected

Definition at line 45 of file sim3.h.

Referenced by inverse(), operator*(), operator[](), and scale().

Eigen::Vector3d g2o::Sim3::t
protected

Definition at line 44 of file sim3.h.

Referenced by operator*(), and translation().


The documentation for this struct was generated from the following file: