3#include <Eigen/Geometry>
14 R = Eigen::Matrix3<g_type>::Identity();
21 SE3mat(
const Eigen::Matrix3<g_type>& R_,
const Eigen::Vector3<g_type>& t_)
30 void Retract(
const Eigen::Vector3<g_type> dr,
const Eigen::Vector3<g_type>& dt)
39 inline Eigen::Vector3<g_type>
operator* (
const Eigen::Vector3<g_type>& v)
const {
52 Eigen::Matrix3<g_type> Rt =
R.transpose();
57 Eigen::Matrix3<g_type>
R;
58 Eigen::Vector3<g_type>
t;
64 static Eigen::Matrix3<g_type>
ExpSO3(
const Eigen::Vector3<g_type> r)
66 Eigen::Matrix3<g_type> W;
71 const g_type theta = r.norm();
73 if (theta < g_type(1e-6))
74 return Eigen::Matrix3<g_type>::Identity() + W + g_type(0.5) * W * W;
76 return Eigen::Matrix3<g_type>::Identity() + W *
sin(theta) / theta + W * W * (1 -
cos(theta)) / (theta * theta);
82 static Eigen::Vector3<g_type>
LogSO3(
const Eigen::Matrix3<g_type>
R)
84 const g_type tr =
R(0, 0) +
R(1, 1) +
R(2, 2);
85 const g_type theta = acos((tr -
static_cast<g_type
>(1)) *
static_cast<g_type
>(0.5));
86 Eigen::Vector3<g_type> w;
87 w <<
R(2, 1) -
R(1, 2),
R(0, 2) -
R(2, 0),
R(1, 0) -
R(0, 1);
88 if (theta < g_type(1e-6))
89 return g_type(0.5) * w;
92 const g_type sin_theta =
sin(theta);
93 if (std::abs(sin_theta) < g_type(1e-10))
97 Eigen::Matrix3<g_type> RpI =
R + Eigen::Matrix3<g_type>::Identity();
99 if (RpI(1, 1) > RpI(0, 0)) max_col = 1;
100 if (RpI(2, 2) > RpI(max_col, max_col)) max_col = 2;
101 Eigen::Vector3<g_type> v = RpI.col(max_col).normalized();
104 return theta * w / (g_type(2.0) * sin_theta);
SE3mat(const Eigen::Matrix3< g_type > &R_, const Eigen::Vector3< g_type > &t_)
Constructs from a rotation matrix and translation vector.
SE3mat()
Default constructor.
static Eigen::Matrix3< g_type > ExpSO3(const Eigen::Vector3< g_type > r)
Computes the exponential map from so(3) to SO(3) (Rodrigues formula).
Eigen::Matrix3< g_type > R
The 3x3 rotation matrix.
Eigen::Vector3< g_type > t
The 3D translation vector.
Eigen::Vector3< g_type > operator*(const Eigen::Vector3< g_type > &v) const
Transforms a 3D point: R*v + t.
static Eigen::Vector3< g_type > LogSO3(const Eigen::Matrix3< g_type > R)
Computes the logarithmic map from SO(3) to so(3).
SE3mat & operator*=(const SE3mat &T2)
In-place composition with another SE3mat transform.
SE3mat inverse() const
Computes the inverse of this rigid transform.
void Retract(const Eigen::Vector3< g_type > dr, const Eigen::Vector3< g_type > &dt)
Applies a retraction update: t += R*dt, R *= ExpSO3(dr).
The primary namespace for the NDEVR SDK.
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type sin(const Angle< t_type > &angle)
Performs optimized sine operation on the given angle using pre-computed lookup table for optimal spee...
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type cos(const Angle< t_type > &angle)
Performs optimized cosine operation on the given angle using pre-computed lookup table for optimal sp...