Now all Eigen::Quaternion flavors are certified as IsGroup
parent
06640cc414
commit
3a6b89e840
|
|
@ -19,47 +19,54 @@
|
|||
|
||||
namespace gtsam {
|
||||
|
||||
/// Typedef to an Eigen Quaternion<double>, we disable alignment because
|
||||
/// geometry objects are stored in boost pool allocators, in Values
|
||||
/// containers, and and these pool allocators do not support alignment.
|
||||
typedef Eigen::Quaternion<double, Eigen::DontAlign> Quaternion;
|
||||
|
||||
namespace traits {
|
||||
/// Define Quaternion to be a model of the Group concept
|
||||
template<>
|
||||
struct structure_category<Quaternion> {
|
||||
/// Define Eigen::Quaternion to be a model of the Group concept
|
||||
template<typename _Scalar, int _Options>
|
||||
struct structure_category<Eigen::Quaternion<_Scalar, _Options> > {
|
||||
typedef group_tag type;
|
||||
};
|
||||
} // \namespace gtsam::traits
|
||||
|
||||
namespace group {
|
||||
|
||||
Quaternion compose(const Quaternion&g, const Quaternion& h) {
|
||||
template<typename _Scalar, int _Options>
|
||||
Eigen::Quaternion<_Scalar, _Options> compose(
|
||||
const Eigen::Quaternion<_Scalar, _Options> &g,
|
||||
const Eigen::Quaternion<_Scalar, _Options> & h) {
|
||||
return g * h;
|
||||
}
|
||||
|
||||
Quaternion between(const Quaternion&g, const Quaternion& h) {
|
||||
template<typename _Scalar, int _Options>
|
||||
Eigen::Quaternion<_Scalar, _Options> between(
|
||||
const Eigen::Quaternion<_Scalar, _Options> &g,
|
||||
const Eigen::Quaternion<_Scalar, _Options> & h) {
|
||||
return g.inverse() * h;
|
||||
}
|
||||
|
||||
Quaternion inverse(const Quaternion&g) {
|
||||
template<typename _Scalar, int _Options>
|
||||
Eigen::Quaternion<_Scalar, _Options> inverse(
|
||||
const Eigen::Quaternion<_Scalar, _Options> &g) {
|
||||
return g.inverse();
|
||||
}
|
||||
|
||||
namespace traits {
|
||||
|
||||
/// Define the trait that specifies Quaternion's identity element
|
||||
template<>
|
||||
struct identity<Quaternion> {
|
||||
static const Quaternion value;
|
||||
typedef Quaternion value_type;
|
||||
/// Declare the trait that specifies a quaternion's identity element
|
||||
template<typename _Scalar, int _Options>
|
||||
struct identity<Eigen::Quaternion<_Scalar, _Options> > {
|
||||
static const Eigen::Quaternion<_Scalar, _Options> value;
|
||||
typedef Eigen::Quaternion<_Scalar, _Options> value_type;
|
||||
};
|
||||
|
||||
const Quaternion identity<Quaternion>::value = Quaternion::Identity();
|
||||
/// Out of line definition of identity
|
||||
template<typename _Scalar, int _Options>
|
||||
const Eigen::Quaternion<_Scalar, _Options> identity<
|
||||
Eigen::Quaternion<_Scalar, _Options> >::value = Eigen::Quaternion<_Scalar,
|
||||
_Options>::Identity();
|
||||
|
||||
/// Define the trait that asserts Quaternion is an additive group
|
||||
template<>
|
||||
struct flavor<Quaternion> {
|
||||
/// Define the trait that asserts quaternions are a multiplicative group
|
||||
template<typename _Scalar, int _Options>
|
||||
struct flavor<Eigen::Quaternion<_Scalar, _Options> > {
|
||||
typedef multiplicative_tag type;
|
||||
};
|
||||
|
||||
|
|
@ -67,6 +74,13 @@ struct flavor<Quaternion> {
|
|||
} // \namespace gtsam::group
|
||||
} // \namespace gtsam
|
||||
|
||||
/**
|
||||
* GSAM typedef to an Eigen::Quaternion<double>, we disable alignment because
|
||||
* geometry objects are stored in boost pool allocators, in Values containers,
|
||||
* and and these pool allocators do not support alignment.
|
||||
*/
|
||||
typedef Eigen::Quaternion<double, Eigen::DontAlign> Quaternion;
|
||||
|
||||
/**
|
||||
* @file testCyclic.cpp
|
||||
* @brief Unit tests for cyclic group
|
||||
|
|
@ -84,25 +98,25 @@ using namespace gtsam;
|
|||
typedef Quaternion Q; // Typedef
|
||||
|
||||
//******************************************************************************
|
||||
TEST(Quaternion, Concept) {
|
||||
BOOST_CONCEPT_ASSERT((IsGroup<Quaternion>));
|
||||
TEST(Quaternion , Concept) {
|
||||
BOOST_CONCEPT_ASSERT((IsGroup<Quaternion >));
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
TEST(Quaternion, Constructor) {
|
||||
Q g(Eigen::AngleAxisd(1, Vector3(0,0,1)));
|
||||
TEST(Quaternion , Constructor) {
|
||||
Q g(Eigen::AngleAxisd(1, Vector3(0, 0, 1)));
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
TEST(Quaternion, Compose) {
|
||||
TEST(Quaternion , Compose) {
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
TEST(Quaternion, Between) {
|
||||
TEST(Quaternion , Between) {
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
TEST(Quaternion, Ivnverse) {
|
||||
TEST(Quaternion , Ivnverse) {
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
|
|
|
|||
Loading…
Reference in New Issue