56 template <
typename Precision =
double>
65 :my_se3(R,T),my_scale(S){}
68 :my_se3(T),my_scale(S){}
70 template<
typename Scalar>
78 return my_se3.get_translation();
83 return my_se3.get_translation();
88 return my_se3.get_rotation();
92 return my_se3.get_rotation();
104 inline Precision& get_scale()
109 inline Precision get_scale()
const 117 get_translation() + get_rotation()*(get_scale()*rhs.get_translation()),
118 get_scale()*rhs.get_scale());
123 return get_rotation()*(P*my_scale)+my_se3.get_translation();
129 const Precision inv_scale= 1./my_scale;
130 return SIM3_(rinv,(-inv_scale)*(rinv*get_translation()),inv_scale);
137 Precision sigma=mu[6];
138 Precision scale=::exp(sigma);
139 Precision theta_sq = r.dot(r);
140 Precision theta = sqrt(theta_sq);
141 Precision half_theta =
static_cast<Precision
>(0.5) * theta;
143 Precision imag_factor;
144 Precision real_factor;
146 if (theta < static_cast<Precision>(1e-10)) {
147 Precision theta_po4 = theta_sq * theta_sq;
148 imag_factor =
static_cast<Precision
>(0.5) -
149 static_cast<Precision
>(1.0 / 48.0) * theta_sq +
150 static_cast<Precision
>(1.0 / 3840.0) * theta_po4;
151 real_factor =
static_cast<Precision
>(1) -
152 static_cast<Precision>(0.5) * theta_sq +
153 static_cast<Precision
>(1.0 / 384.0) * theta_po4;
155 Precision sin_half_theta = sin(half_theta);
156 imag_factor = sin_half_theta / theta;
157 real_factor = cos(half_theta);
161 if (abs(sigma) < NEAR_ZERO) {
163 if (abs(theta) < NEAR_ZERO) {
165 B =
static_cast<Precision
>(1. / 6.);
167 Precision theta_sq = theta * theta;
168 A = (1. - cos(theta)) / theta_sq;
169 B = (theta - sin(theta)) / (theta_sq * theta);
172 C = (scale - 1.) / sigma;
173 if (abs(theta) < NEAR_ZERO) {
174 Precision sigma_sq = sigma * sigma;
175 A = ((sigma - 1.) * scale + 1.) / sigma_sq;
176 B = ((0.5 * sigma_sq - sigma + 1.) * scale) / (sigma_sq * sigma);
178 Precision a = scale * sin(theta);
179 Precision b = scale * cos(theta);
180 Precision c = theta_sq + sigma * sigma;
181 A = (a * sigma + (1. - b) * theta) / (theta * c);
182 B = (C - ((b - 1.) * sigma + a * theta) / (c)) * 1. / (theta_sq);
186 SO3_<Precision> R( imag_factor * r.x, imag_factor * r.y,imag_factor * r.z,real_factor);
188 auto t= A*rcp+B*r.cross(rcp)+C*p;
194 const auto& l=get_rotation();
195 const auto& t=get_translation();
196 const auto& scale=my_scale;
197 const Precision squared_w = l.w*l.w;
198 const Precision n = sqrt(l.x*l.x+l.y*l.y+l.z*l.z);
199 const Precision sigma= ::log(scale);
206 A_inv = 2./l.w - 2.*(1.0-squared_w)/(l.w*squared_w);
210 if (fabs(l.w)<NEAR_ZERO)
223 A_inv = 2*atan(n/l.w)/n;
226 Precision theta=A_inv*n;
229 const Precision scale_sq = scale * scale;
230 const Precision theta_sq = theta * theta;
231 const Precision sin_theta = sin(theta);
232 const Precision cos_theta = cos(theta);
235 if (abs(sigma * sigma) < NEAR_ZERO) {
236 c = 1. - 0.5 * sigma;
238 if (abs(theta_sq) < NEAR_ZERO) {
239 b = Precision(1. / 12.);
241 b = (theta * sin_theta + 2. * cos_theta - 2.) /
242 (2. * theta_sq * (cos_theta - 1.));
245 const Precision scale_cu = scale_sq * scale;
246 c = sigma / (scale - 1.);
247 if (abs(theta_sq) < NEAR_ZERO) {
248 a = (-sigma * scale + scale - 1.) / ((scale - 1.) * (scale - 1.));
249 b = (scale_sq * sigma - 2. * scale_sq + scale * sigma + 2. * scale) /
250 (2. * scale_cu - 6. * scale_sq + 6. * scale - 2.);
252 const Precision s_sin_theta = scale * sin_theta;
253 const Precision s_cos_theta = scale * cos_theta;
254 a = (theta * s_cos_theta - theta - sigma * s_sin_theta) /
255 (theta * (scale_sq - 2. * s_cos_theta + 1.));
257 (theta * s_sin_theta - theta * sin_theta + sigma * s_cos_theta -
258 scale * sigma + sigma * cos_theta - sigma) /
259 (theta_sq * (scale_cu - 2. * scale * s_cos_theta - scale_sq +
260 2. * s_cos_theta + scale - 1.));
264 auto rcrosst=r.cross(t);
272 #ifdef SOPHUS_SIM3_HPP 273 SIM3_(
const Sophus::Sim3Group<Precision>& sim3)
275 Eigen::Quaternion<Precision> quat(sim3.rxso3().quaternion().coeffs());
277 get_rotation()=Sophus::SO3Group<Precision>(quat);
279 get_scale()=sim3.scale();
281 operator Sophus::Sim3Group<Precision>()
283 auto translation=get_translation();
284 return Sophus::Sim3Group<Precision>(Sophus::RxSO3Group<Precision>(std::sqrt(get_scale()),
286 Eigen::Map<Eigen::Matrix<Precision, 3, 1>>(&translation.x));
3D rotation represented by the quaternion.
Definition: SO3.h:131
SIM3_()
Default constructor. Initialises the the rotation to zero (the identity), the scale to one and the tr...
Definition: SIM3.h:62
Represent a three-dimensional similarity transformation,7 degrees of freedom a rotation: R (Here is r...
Definition: SIM3.h:57
Represent a three-dimensional Euclidean transformation (a rotation and a translation).
Definition: SE3.h:69