19 #ifndef SNARK_VISITING_EIGEN_H
20 #define SNARK_VISITING_EIGEN_H
23 #include <Eigen/Geometry>
24 #include <comma/visiting/apply.h>
25 #include <comma/visiting/visit.h>
27 namespace comma {
namespace visiting {
29 template <
typename T >
struct traits< ::Eigen::Matrix< T, 2, 1 > >
31 template <
typename Key,
class Visitor >
32 static void visit(
const Key&, ::Eigen::Matrix< T, 2, 1 >& p, Visitor& v )
34 v.apply(
"x", p.x() );
35 v.apply(
"y", p.y() );
38 template <
typename Key,
class Visitor >
39 static void visit(
const Key&, const ::Eigen::Matrix< T, 2, 1 >& p, Visitor& v )
41 v.apply(
"x", p.x() );
42 v.apply(
"y", p.y() );
46 template <
typename T >
struct traits< ::Eigen::Matrix< T, 3, 1 > >
48 template <
typename Key,
class Visitor >
49 static void visit(
const Key&, ::Eigen::Matrix< T, 3, 1 >& p, Visitor& v )
51 v.apply(
"x", p.x() );
52 v.apply(
"y", p.y() );
53 v.apply(
"z", p.z() );
56 template <
typename Key,
class Visitor >
57 static void visit(
const Key&, const ::Eigen::Matrix< T, 3, 1 >& p, Visitor& v )
59 v.apply(
"x", p.x() );
60 v.apply(
"y", p.y() );
61 v.apply(
"z", p.z() );
65 template <
typename T >
struct traits< ::Eigen::Matrix< T, 4, 1 > >
67 template <
typename Key,
class Visitor >
68 static void visit(
const Key&, ::Eigen::Matrix< T, 4, 1 >& p, Visitor& v )
70 v.apply(
"x", p.x() );
71 v.apply(
"y", p.y() );
72 v.apply(
"z", p.z() );
73 v.apply(
"w", p.w() );
76 template <
typename Key,
class Visitor >
77 static void visit(
const Key&, const ::Eigen::Matrix< T, 4, 1 >& p, Visitor& v )
79 v.apply(
"x", p.x() );
80 v.apply(
"y", p.y() );
81 v.apply(
"z", p.z() );
82 v.apply(
"w", p.w() );
87 template <
typename T >
struct traits< ::Eigen::Quaternion< T > >
89 template <
typename Key,
class Visitor >
90 static void visit(
const Key&, ::Eigen::Quaternion< T >& p, Visitor& v )
92 v.apply(
"x", p.x() );
93 v.apply(
"y", p.y() );
94 v.apply(
"z", p.z() );
95 v.apply(
"w", p.w() );
98 template <
typename Key,
class Visitor >
99 static void visit(
const Key&, const ::Eigen::Quaternion< T >& p, Visitor& v )
101 v.apply(
"x", p.x() );
102 v.apply(
"y", p.y() );
103 v.apply(
"z", p.z() );
104 v.apply(
"w", p.w() );
108 template <
typename T >
struct traits< ::Eigen::Translation< T, 3 > >
110 template <
typename Key,
class Visitor >
111 static void visit(
const Key&, ::Eigen::Translation< T, 3 >& p, Visitor& v )
113 v.apply(
"x", p.vector().x() );
114 v.apply(
"y", p.vector().y() );
115 v.apply(
"z", p.vector().z() );
118 template <
typename Key,
class Visitor >
119 static void visit(
const Key&, const ::Eigen::Translation< T, 3 >& p, Visitor& v )
121 v.apply(
"x", p.vector().x() );
122 v.apply(
"y", p.vector().y() );
123 v.apply(
"z", p.vector().z() );
130 #endif // SNARK_VISITING_EIGEN_H