Macros. Too ugly?
parent
19c38b91ee
commit
38a0842090
|
|
@ -149,6 +149,17 @@ check_invariants(const T& a, const T& b, double tol = 1e-9) {
|
||||||
}
|
}
|
||||||
} // \ namespace group
|
} // \ namespace group
|
||||||
|
|
||||||
|
#define GTSAM_MULTIPLICATIVE_GROUP2(T1,A1,T2,A2,GROUP) \
|
||||||
|
namespace group { \
|
||||||
|
template<T1 A1, T2 A2> GROUP<A1,A2> compose(const GROUP<A1,A2> &g, const GROUP<A1,A2> & h) { return g * h;} \
|
||||||
|
template<T1 A1, T2 A2> GROUP<A1,A2> between(const GROUP<A1,A2> &g, const GROUP<A1,A2> & h) { return g.inverse() * h;} \
|
||||||
|
template<T1 A1, T2 A2> GROUP<A1,A2> inverse(const GROUP<A1,A2> &g) { return g.inverse();} \
|
||||||
|
namespace traits { \
|
||||||
|
template<T1 A1, T2 A2> struct identity<GROUP<A1,A2> > { static const GROUP<A1,A2> value; typedef GROUP<A1,A2> value_type;};\
|
||||||
|
template<T1 A1, T2 A2> const GROUP<A1,A2> identity<GROUP<A1,A2> >::value = GROUP<A1,A2>::Identity();\
|
||||||
|
template<T1 A1, T2 A2> struct flavor<GROUP<A1,A2> > { typedef multiplicative_tag type;};\
|
||||||
|
}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group Concept
|
* Group Concept
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -111,47 +111,8 @@ struct DefaultChart<Eigen::Quaternion<S, O> > {
|
||||||
} // \namespace gtsam::manifold::traits
|
} // \namespace gtsam::manifold::traits
|
||||||
} // \namespace gtsam::manifold
|
} // \namespace gtsam::manifold
|
||||||
|
|
||||||
namespace group {
|
GTSAM_MULTIPLICATIVE_GROUP2(typename,_Scalar, int,_Options ,Eigen::Quaternion)
|
||||||
|
|
||||||
template<typename S, int O>
|
|
||||||
Eigen::Quaternion<S, O> compose(const Eigen::Quaternion<S, O> &g,
|
|
||||||
const Eigen::Quaternion<S, O> & h) {
|
|
||||||
return g * h;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename S, int O>
|
|
||||||
Eigen::Quaternion<S, O> between(const Eigen::Quaternion<S, O> &g,
|
|
||||||
const Eigen::Quaternion<S, O> & h) {
|
|
||||||
return g.inverse() * h;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename S, int O>
|
|
||||||
Eigen::Quaternion<S, O> inverse(const Eigen::Quaternion<S, O> &g) {
|
|
||||||
return g.inverse();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace traits {
|
|
||||||
|
|
||||||
/// Declare the trait that specifies a quaternion's identity element
|
|
||||||
template<typename S, int O>
|
|
||||||
struct identity<Eigen::Quaternion<S, O> > {
|
|
||||||
static const Eigen::Quaternion<S, O> value;
|
|
||||||
typedef Eigen::Quaternion<S, O> value_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Out of line definition of identity
|
|
||||||
template<typename S, int O>
|
|
||||||
const Eigen::Quaternion<S, O> identity<Eigen::Quaternion<S, O> >::value =
|
|
||||||
Eigen::Quaternion<S, O>::Identity();
|
|
||||||
|
|
||||||
/// Define the trait that asserts quaternions are a multiplicative group
|
|
||||||
template<typename S, int O>
|
|
||||||
struct flavor<Eigen::Quaternion<S, O> > {
|
|
||||||
typedef multiplicative_tag type;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // \namespace gtsam::group::traits
|
|
||||||
} // \namespace gtsam::group
|
|
||||||
} // \namespace gtsam
|
} // \namespace gtsam
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue