diff --git a/gtsam/geometry/BearingRange.h b/gtsam/geometry/BearingRange.h index b9e074d48..27fe2f197 100644 --- a/gtsam/geometry/BearingRange.h +++ b/gtsam/geometry/BearingRange.h @@ -25,16 +25,23 @@ namespace gtsam { -// forward declaration of Bearing functor, assumed partially specified +// Forward declaration of Bearing functor which should be of A1*A2 -> return_type +// For example Bearing(pose,point), defined in Pose3.h will return Unit3 +// At time of writing only Pose2 and Pose3 specialize this functor. template struct Bearing; -// forward declaration of Range functor, assumed partially specified +// Forward declaration of Range functor which should be of A1*A2 -> return_type +// For example Range(T1,T2), defined in Pose2.h will return double +// At time of writing Pose2, Pose3, and several Camera variants specialize this for several types template struct Range; /** - * Bearing-Range product for a particular A1,A2 combination + * Bearing-Range product for a particular A1,A2 combination will use the functors above to create + * a similar functor of type A1*A2 -> pair + * For example BearingRange(pose,point) will return pair + * and BearingRange(pose,point) will return pair */ template struct BearingRange @@ -88,31 +95,37 @@ struct BearingRange friend class boost::serialization::access; }; +// Declare this to be both Testable and a Manifold template struct traits > : Testable >, internal::ManifoldTraits > {}; // Helper class for to implement Range traits for classes with a bearing method -template +// For example, to specialize Bearing to Pose3 and Point3, using Pose3::bearing, it suffices to say +// template <> struct Bearing : HasBearing {}; +// where the third argument is used to indicate the return type +template struct HasBearing { - typedef T result_type; - T operator()( + typedef RT result_type; + RT operator()( const A1& a1, const A2& a2, - OptionalJacobian::dimension, traits::dimension> H1, - OptionalJacobian::dimension, traits::dimension> H2) { + OptionalJacobian::dimension, traits::dimension> H1, + OptionalJacobian::dimension, traits::dimension> H2) { return a1.bearing(a2, H1, H2); } }; -// Helper class for to implement Range traits for classes with a range method -template +// Similar helper class for to implement Range traits for classes with a range method +// For classes with overloaded range methods, such as SimpleCamera, this can even be templated: +// template struct Range : HasRange {}; +template struct HasRange { - typedef T result_type; - T operator()( + typedef RT result_type; + RT operator()( const A1& a1, const A2& a2, - OptionalJacobian::dimension, traits::dimension> H1, - OptionalJacobian::dimension, traits::dimension> H2) { + OptionalJacobian::dimension, traits::dimension> H1, + OptionalJacobian::dimension, traits::dimension> H2) { return a1.range(a2, H1, H2); } };