g2o
Loading...
Searching...
No Matches
isometry3d_mappings.h
Go to the documentation of this file.
1// g2o - General Graph Optimization
2// Copyright (C) 2011 H. Strasdat, G. Grisetti, R. Kümmerle, W. Burgard
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright notice,
10// this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above copyright
12// notice, this list of conditions and the following disclaimer in the
13// documentation and/or other materials provided with the distribution.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27#ifndef G2O_ISOMETRY3D_MAPPINGS_H_
28#define G2O_ISOMETRY3D_MAPPINGS_H_
29
30#include <Eigen/Core>
31
33#include "se3quat.h"
34
35namespace g2o {
36
42namespace internal {
43
55inline Isometry3::ConstLinearPart extractRotation(const Isometry3& A) {
56 return A.matrix().topLeftCorner<3, 3>();
57}
58
65template <typename Derived>
66void nearestOrthogonalMatrix(const Eigen::MatrixBase<Derived>& R) {
67 Eigen::JacobiSVD<Matrix3> svd(R, Eigen::ComputeFullU | Eigen::ComputeFullV);
68 double det = (svd.matrixU() * svd.matrixV().adjoint()).determinant();
69 Matrix3 scaledU(svd.matrixU());
70 scaledU.col(0) /= det;
71 const_cast<Eigen::MatrixBase<Derived>&>(R) =
72 scaledU * svd.matrixV().transpose();
73}
74
80template <typename Derived>
81void approximateNearestOrthogonalMatrix(const Eigen::MatrixBase<Derived>& R) {
82 Matrix3 E = R.transpose() * R;
83 E.diagonal().array() -= 1;
84 const_cast<Eigen::MatrixBase<Derived>&>(R) -= 0.5 * R * E;
85}
86
95
96// functions to handle the rotation part
114
115// functions to handle the toVector of the whole transformations
128
141
150
151} // end namespace internal
152} // end namespace g2o
153
154#endif
#define G2O_TYPES_SLAM3D_API
Isometry3 fromVectorQT(const Vector7 &v)
SE3Quat toSE3Quat(const Isometry3 &t)
Vector3 toEuler(const Matrix3 &R)
void nearestOrthogonalMatrix(const Eigen::MatrixBase< Derived > &R)
Isometry3 fromVectorMQT(const Vector6 &v)
Vector6 toVectorMQT(const Isometry3 &t)
Vector3 toCompactQuaternion(const Matrix3 &R)
Quaternion normalized(const Quaternion &q)
Matrix3 fromCompactQuaternion(const Vector3 &v)
Quaternion & normalize(Quaternion &q)
void approximateNearestOrthogonalMatrix(const Eigen::MatrixBase< Derived > &R)
Matrix3 fromEuler(const Vector3 &v)
Vector6 toVectorET(const Isometry3 &t)
Vector7 toVectorQT(const Isometry3 &t)
Isometry3 fromVectorET(const Vector6 &v)
Isometry3 fromSE3Quat(const SE3Quat &t)
Isometry3::ConstLinearPart extractRotation(const Isometry3 &A)
VectorN< 3 > Vector3
Definition eigen_types.h:51
VectorN< 7 > Vector7
Definition eigen_types.h:54
MatrixN< 3 > Matrix3
Definition eigen_types.h:72
Eigen::Transform< double, 3, Eigen::Isometry, Eigen::ColMajor > Isometry3
Definition eigen_types.h:77
VectorN< 6 > Vector6
Definition eigen_types.h:53
Eigen::Quaternion< double > Quaternion
Definition eigen_types.h:81