21 #include <gtsam/config.h> 23 #ifndef GTSAM_USE_QUATERNIONS 34 Rot3::Rot3() : rot_(I_3x3) {}
39 R << col1, col2, col3;
45 double R23,
double R31,
double R32,
double R33) {
47 R << R11,
R12, R13, R21, R22, R23, R31, R32, R33;
57 double st =
sin(t), ct =
cos(t);
66 double st =
sin(t), ct =
cos(t);
75 double st =
sin(t), ct =
cos(t);
88 double cz=
cos(z),sz=
sin(z);
99 double ssc = ss_ * cz, csc = cs_ * cz, sss = ss_ * sz, css = cs_ * sz;
100 if (Hx) (*Hx) << 1, 0, 0;
101 if (Hy) (*Hy) << 0,
cx, -sx;
102 if (Hz) (*Hz) << -sy, sc_, cc_;
104 _cc,- c_s + ssc, s_s + csc,
105 _cs, c_c + sss, -s_c + css,
124 Vector3 x = rot.block<1, 3>(0, 0),
y = rot.block<1, 3>(1, 0);
127 Vector3 x_ort = x - (error / 2) *
y, y_ort =
y - (error / 2) *
x;
128 Vector3 z_ort = x_ort.cross(y_ort);
130 rot_orth.block<1, 3>(0, 0) = 0.5 * (3 - x_ort.dot(x_ort)) * x_ort;
131 rot_orth.block<1, 3>(1, 0) = 0.5 * (3 - y_ort.dot(y_ort)) * y_ort;
132 rot_orth.block<1, 3>(2, 0) = 0.5 * (3 - z_ort.dot(z_ort)) * z_ort;
134 return Rot3(rot_orth);
163 if (H)
throw std::runtime_error(
"Rot3::CayleyChart::Retract Derivative");
165 const double x2 = x *
x, y2 =
y *
y,
z2 =
z *
z;
166 const double xy = x *
y, xz = x *
z, yz = y *
z;
167 const double f = 1.0 / (4.0 + x2 + y2 +
z2), _2f = 2.0 * f;
168 return Rot3((4 + x2 - y2 - z2) * f, (xy - 2 * z) * _2f, (xz + 2 * y) * _2f,
169 (xy + 2 * z) * _2f, (4 - x2 + y2 - z2) * f, (yz - 2 * x) * _2f,
170 (xz - 2 * y) * _2f, (yz + 2 * x) * _2f, (4 - x2 - y2 + z2) * f);
175 if (H)
throw std::runtime_error(
"Rot3::CayleyChart::Local Derivative");
181 throw std::runtime_error(
"Rot3::CayleyChart::Local Invalid Rotation");
189 const double a = A(0, 0),
b = A(0, 1),
c = A(0, 2);
190 const double d = A(1, 0),
e = A(1, 1),
f = A(1, 2);
191 const double g = A(2, 0),
h = A(2, 1),
i = A(2, 2);
192 const double di = d *
i, ce =
c *
e, cd =
c *
d, fg =
f *
g;
193 const double M = 1 + e -
f *
h + i + e *
i;
194 const double K = -4.0 / (cd *
h + M + a * M - g * (
c + ce) -
b * (d + di - fg));
195 const double x = a *
f - cd +
f;
196 const double y =
b * f - ce -
c;
197 const double z = fg - di -
d;
206 else throw std::runtime_error(
"Rot3::Retract: unknown mode");
214 else throw std::runtime_error(
"Rot3::Local: unknown mode");
int EIGEN_BLAS_FUNC() rot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps)
static Rot3 RzRyRx(double x, double y, double z, OptionalJacobian< 3, 1 > Hx={}, OptionalJacobian< 3, 1 > Hy={}, OptionalJacobian< 3, 1 > Hz={})
Rotations around Z, Y, then X axes as in http://en.wikipedia.org/wiki/Rotation_matrix, counterclockwise when looking from unchanging axis.
Matrix< RealScalar, Dynamic, Dynamic > M
Jet< T, N > cos(const Jet< T, N > &f)
Point3 r1() const
first column
void determinant(const MatrixType &m)
Use the Lie group exponential map to retract.
Rot2 R(Rot2::fromAngle(0.1))
Jet< T, N > sin(const Jet< T, N > &f)
Rot3 operator*(const Rot3 &R2) const
Syntatic sugar for composing two rotations.
static Rot3 Retract(const Vector3 &v, ChartJacobian H={})
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
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
3*3 matrix representation of SO(3)
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
static Rot3 Expmap(const Vector3 &v, OptionalJacobian< 3, 3 > H={})
void g(const string &key, int i)
static Rot3 Retract(const Vector3 &v, OptionalJacobian< 3, 3 > H={})
Point3 r2() const
second column
static Vector3 Local(const Rot3 &r, OptionalJacobian< 3, 3 > H={})
Retract and localCoordinates using the Cayley transform.
static Rot3 Rx(double t)
Rotation around X axis as in http://en.wikipedia.org/wiki/Rotation_matrix, counterclockwise when look...
static EIGEN_DEVICE_FUNC Matrix< Scalar, 2, 2 > toRotationMatrix(const Scalar &s)
static Vector3 Logmap(const Rot3 &R, OptionalJacobian< 3, 3 > H={})
const MatrixNN & matrix() const
Return matrix.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Vector::Scalar omega(const Vector &t, const Vector &s, RealScalar angle)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DEVICE_FUNC const Scalar & q
#define ROT3_DEFAULT_COORDINATES_MODE
gtsam::Quaternion toQuaternion() const
Matrix3 skewSymmetric(double wx, double wy, double wz)
static TangentVector Logmap(const SO &R, ChartJacobian H={})
static Rot3 Rz(double t)
Rotation around Z axis as in http://en.wikipedia.org/wiki/Rotation_matrix, counterclockwise when look...
The quaternion class used to represent 3D orientations and rotations.
static const DiscreteKey mode(modeKey, 2)
static Vector3 Local(const Rot3 &r, ChartJacobian H={})
Point3 rotate(const Point3 &p, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
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 x
Matrix3 transpose() const
static Rot3 Ry(double t)
Rotation around Y axis as in http://en.wikipedia.org/wiki/Rotation_matrix, counterclockwise when look...
Point3 r3() const
third column
3D rotation represented as a rotation matrix or quaternion
Eigen::Quaternion< double, Eigen::DontAlign > Quaternion