Go to the documentation of this file.
36 static constexpr
double one_6th = 1.0 / 6.0;
48 H << I_3x3 *
R(0, 0), I_3x3 *
R(1, 0), I_3x3 *
R(2, 0),
49 I_3x3 *
R(0, 1), I_3x3 *
R(1, 1), I_3x3 *
R(2, 1),
50 I_3x3 *
R(0, 2), I_3x3 *
R(1, 2), I_3x3 *
R(2, 2);
56 Matrix3 MR =
M *
R.matrix();
68 const double one_minus_cos =
88 : theta2(angle * angle),
129 Matrix3 doubleCrossJacobian;
136 *
H = - WWv *
F *
omega.transpose() +
C * doubleCrossJacobian;
144 Matrix3 D_BWv_w, D_CWWv_w;
147 if (H1) *H1 = -D_BWv_w + D_CWWv_w;
149 return v - BWv + CWWv;
168 Matrix3 D_BWv_w, D_CWWv_w;
171 if (H1) *H1 = D_BWv_w + D_CWWv_w;
173 return v + BWv + CWWv;
202 SO3 SO3::ClosestTo(
const Matrix3&
M) {
204 const auto&
U =
svd.matrixU();
205 const auto&
V =
svd.matrixV();
207 return SO3(
U *
Vector3(1, 1, det).asDiagonal() *
V.transpose());
213 SO3 SO3::ChordalMean(
const std::vector<SO3>& rotations) {
218 for (
const auto& R_i : rotations) {
221 return ClosestTo(C_e);
234 Vector3 SO3::Vee(
const Matrix3&
X) {
245 Matrix3 SO3::AdjointMap()
const {
254 so3::DexpFunctor impl(
omega);
256 return impl.expmap();
258 return so3::ExpmapFunctor(
omega).expmap();
265 return so3::DexpFunctor(
omega).dexp();
290 const Matrix3
W = Hat(
omega);
291 return I_3x3 + 0.5 *
W +
292 (1 / (theta * theta) - (1 +
cos(theta)) / (2 * theta *
sin(theta))) *
304 const Matrix3&
R =
Q.matrix();
305 const double &R11 =
R(0, 0),
R12 =
R(0, 1), R13 =
R(0, 2);
306 const double &R21 =
R(1, 0), R22 =
R(1, 1), R23 =
R(1, 2);
307 const double &R31 =
R(2, 0), R32 =
R(2, 1), R33 =
R(2, 2);
310 const double tr =
R.trace();
316 if (tr + 1.0 < 1
e-3) {
317 if (R33 > R22 && R33 > R11) {
319 const double W = R21 -
R12;
320 const double Q1 = 2.0 + 2.0 * R33;
321 const double Q2 = R31 + R13;
322 const double Q3 = R23 + R32;
323 const double r =
sqrt(
Q1);
324 const double one_over_r = 1 / r;
326 const double sgn_w =
W < 0 ? -1.0 : 1.0;
327 const double mag =
M_PI - (2 * sgn_w *
W) / norm;
328 const double scale = 0.5 * one_over_r * mag;
330 }
else if (R22 > R11) {
332 const double W = R13 - R31;
333 const double Q1 = 2.0 + 2.0 * R22;
334 const double Q2 = R23 + R32;
335 const double Q3 =
R12 + R21;
336 const double r =
sqrt(
Q1);
337 const double one_over_r = 1 / r;
339 const double sgn_w =
W < 0 ? -1.0 : 1.0;
340 const double mag =
M_PI - (2 * sgn_w *
W) / norm;
341 const double scale = 0.5 * one_over_r * mag;
345 const double W = R32 - R23;
346 const double Q1 = 2.0 + 2.0 * R11;
347 const double Q2 =
R12 + R21;
348 const double Q3 = R31 + R13;
349 const double r =
sqrt(
Q1);
350 const double one_over_r = 1 / r;
352 const double sgn_w =
W < 0 ? -1.0 : 1.0;
353 const double mag =
M_PI - (2 * sgn_w *
W) / norm;
354 const double scale = 0.5 * one_over_r * mag;
359 const double tr_3 = tr - 3.0;
362 double theta =
acos((tr - 1.0) / 2.0);
363 magnitude = theta / (2.0 *
sin(theta));
368 magnitude = 0.5 - tr_3 / 12.0 + tr_3*tr_3/60.0;
373 if (
H) *
H = LogmapDerivative(
omega);
388 Vector3 SO3::ChartAtOrigin::Local(
const SO3&
R, ChartJacobian
H) {
394 static Vector9
vec3(
const Matrix3&
R) {
399 static std::vector<Matrix3>
G3({SO3::Hat(Vector3::Unit(0)),
400 SO3::Hat(Vector3::Unit(1)),
401 SO3::Hat(Vector3::Unit(2))});
411 const Matrix3&
R = matrix_;
414 *
H <<
R *
P3.block<3, 3>(0, 0),
R *
P3.block<3, 3>(3, 0),
415 R *
P3.block<3, 3>(6, 0);
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
static SO AxisAngle(const Vector3 &axis, double theta)
Constructor from axis and angle. Only defined for SO3.
Vector3 applyLeftJacobian(const Vector3 &v, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
Multiplies with leftJacobian(), with optional derivatives.
static constexpr double one_180th
typedef and functions to augment Eigen's VectorXd
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Jet< T, N > sin(const Jet< T, N > &f)
Vector3 applyDexp(const Vector3 &v, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
Multiplies with dexp(), with optional derivatives.
typedef and functions to augment Eigen's MatrixXd
Matrix3 rightJacobianInverse() const
Inverse of right Jacobian.
static constexpr double one_120th
ExpmapFunctor(const Vector3 &omega, bool nearZeroApprox=false)
Constructor with element of Lie algebra so(3)
static Vector9 vec3(const Matrix3 &R)
static constexpr double one_24th
static constexpr double one_60th
Matrix3 skewSymmetric(double wx, double wy, double wz)
cout<< "Here is the matrix m:"<< endl<< m<< endl;JacobiSVD< MatrixXf > svd(m, ComputeThinU|ComputeThinV)
Jet< T, N > acos(const Jet< T, N > &f)
void determinant(const MatrixType &m)
Jet< T, N > cos(const Jet< T, N > &f)
3*3 matrix representation of SO(3)
static constexpr double one_720th
Pose2_ Expmap(const Vector3_ &xi)
Vector3 crossB(const Vector3 &v, OptionalJacobian< 3, 3 > H={}) const
Computes B * (omega x v).
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics scale
Point3 cross(const Point3 &p, const Point3 &q, OptionalJacobian< 3, 3 > H1, OptionalJacobian< 3, 3 > H2)
cross product
const MatrixNN & matrix() const
Return matrix.
Vector3 doubleCrossC(const Vector3 &v, OptionalJacobian< 3, 3 > H={}) const
Computes C * (omega x (omega x v)).
double dot(const V1 &a, const V2 &b)
static std::vector< Matrix3 > G3({SO3::Hat(Vector3::Unit(0)), SO3::Hat(Vector3::Unit(1)), SO3::Hat(Vector3::Unit(2))})
static constexpr double one_6th
Vector3 applyInvDexp(const Vector3 &v, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
Multiplies with dexp().inverse(), with optional derivatives.
A matrix or vector expression mapping an existing array of data.
Vector3 applyLeftJacobianInverse(const Vector3 &v, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
Multiplies with leftJacobianInverse(), with optional derivatives.
Two-sided Jacobi SVD decomposition of a rectangular matrix.
SO3 expmap() const
Rodrigues formula.
The quaternion class used to represent 3D orientations and rotations.
Matrix3 leftJacobian() const
GTSAM_EXPORT Matrix99 Dcompose(const SO3 &Q)
(constant) Jacobian of compose wrpt M
Matrix3 rightJacobian() const
Array< int, Dynamic, 1 > v
DexpFunctor(const Vector3 &omega, bool nearZeroApprox=false)
Constructor with element of Lie algebra so(3)
void init(bool nearZeroApprox=false)
Matrix3 leftJacobianInverse() const
Jet< T, N > sqrt(const Jet< T, N > &f)
static constexpr double one_12th
static constexpr double one_1260th
Eigen::Matrix< double, 9, 3 > Matrix93
Rot2 R(Rot2::fromAngle(0.1))
GTSAM_EXPORT Matrix3 compose(const Matrix3 &M, const SO3 &R, OptionalJacobian< 9, 9 > H)
Point3 doubleCross(const Point3 &p, const Point3 &q, OptionalJacobian< 3, 3 > H1, OptionalJacobian< 3, 3 > H2)
double cross product
Matrix< RealScalar, Dynamic, Dynamic > M
gtsam
Author(s):
autogenerated on Wed Jan 1 2025 04:03:26