19 #ifndef SNARK_MATH_RBE_H
20 #define SNARK_MATH_RBE_H
23 #include <comma/math/compare.h>
36 double range()
const {
return m_rbe[0]; }
37 double bearing()
const {
return m_rbe[0]; }
38 double elevation()
const {
return m_rbe[0]; }
42 double b()
const {
return bearing(); }
43 double e()
const {
return elevation(); }
46 void range(
double t );
47 void bearing(
double t );
48 void elevation(
double t );
50 Eigen::Vector3d to_cartesian()
const;
53 Eigen::Vector3d m_rbe;
58 if( !comma::math::less( t, 0 ) )
70 void range_bearing_elevation::bearing(
double t )
72 double b( std::fmod( t, (
double )( M_PI * 2 ) ) );
73 if( !comma::math::less( b, M_PI ) ) { b -= ( M_PI * 2 ); }
74 else if( comma::math::less( b, -M_PI ) ) { b += ( M_PI * 2 ); }
78 void range_bearing_elevation::elevation(
double t )
80 double e( std::fmod( t, (
double )( M_PI * 2 ) ) );
81 if( comma::math::less( e, 0 ) ) { e += M_PI * 2; }
82 if( !comma::math::less( e, M_PI / 2 ) )
84 if( !comma::math::less( e, M_PI ) )
86 if( !comma::math::less( e, M_PI * 3 / 2 ) )
93 bearing( bearing() + M_PI );
99 bearing( bearing() + M_PI );
105 Eigen::Vector3d range_bearing_elevation::to_cartesian()
const
107 double xyProjection(
range() * std::cos( elevation() ) );
108 return ::Eigen::Matrix< double, 3, 1 >( xyProjection * std::cos( bearing() )
109 , xyProjection * std::sin( bearing() )
110 ,
range() * std::sin( elevation() ) );
115 namespace comma {
namespace visiting {
119 struct traits< snark::range_bearing_elevation >
122 template <
typename Key,
class Visitor >
125 v.apply(
"range", p.
range() );
126 v.apply(
"bearing", p.bearing() );
127 v.apply(
"elevation", p.elevation() );
131 template <
typename Key,
class Visitor >
137 v.apply(
"range", r );
138 v.apply(
"bearing", b );
139 v.apply(
"elevation", e );
146 #endif // SNARK_MATH_RBE_H