29 typedef Eigen::Matrix<double, N, 1> TangentVector;
31 typedef Eigen::Matrix<double, N, N> Jacobian;
32 static int GetDimension(
const Class&) {
return N;}
34 static TangentVector Local(
const Class& origin,
const Class& other,
35 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
36 if (H1) *H1 = - Jacobian::Identity();
37 if (H2) *H2 = Jacobian::Identity();
38 Class v = other-origin;
42 static Class Retract(
const Class& origin,
const TangentVector& v,
43 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
44 if (H1) *H1 = Jacobian::Identity();
45 if (H2) *H2 = Jacobian::Identity();
54 static TangentVector Logmap(
const Class& m, ChartJacobian Hm = boost::none) {
55 if (Hm) *Hm = Jacobian::Identity();
59 static Class Expmap(
const TangentVector& v, ChartJacobian Hv = boost::none) {
60 if (Hv) *Hv = Jacobian::Identity();
64 static Class Compose(
const Class& v1,
const Class& v2, ChartJacobian H1 = boost::none,
65 ChartJacobian H2 = boost::none) {
66 if (H1) *H1 = Jacobian::Identity();
67 if (H2) *H2 = Jacobian::Identity();
71 static Class Between(
const Class& v1,
const Class& v2, ChartJacobian H1 = boost::none,
72 ChartJacobian H2 = boost::none) {
73 if (H1) *H1 = - Jacobian::Identity();
74 if (H2) *H2 = Jacobian::Identity();
78 static Class Inverse(
const Class& v, ChartJacobian H = boost::none) {
79 if (H) *H = - Jacobian::Identity();
92 static Class Compose(
const Class& v1,
const Class& v2) {
return v1+v2;}
93 static Class Between(
const Class& v1,
const Class& v2) {
return v2-v1;}
94 static Class Inverse(
const Class& m) {
return -m;}
99 typedef Eigen::VectorXd TangentVector;
101 static int GetDimension(
const Class& m) {
return m.dim();}
103 static Eigen::MatrixXd Eye(
const Class& m) {
104 int dim = GetDimension(m);
105 return Eigen::MatrixXd::Identity(dim, dim);
108 static TangentVector Local(
const Class& origin,
const Class& other,
109 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
110 if (H1) *H1 = - Eye(origin);
111 if (H2) *H2 = Eye(other);
112 Class v = other-origin;
116 static Class Retract(
const Class& origin,
const TangentVector& v,
117 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
118 if (H1) *H1 = Eye(origin);
119 if (H2) *H2 = Eye(origin);
128 static TangentVector Logmap(
const Class& m, ChartJacobian Hm = boost::none) {
129 if (Hm) *Hm = Eye(m);
133 static Class Expmap(
const TangentVector& v, ChartJacobian Hv = boost::none) {
140 static Class Compose(
const Class& v1,
const Class& v2, ChartJacobian H1,
141 ChartJacobian H2 = boost::none) {
142 if (H1) *H1 = Eye(v1);
143 if (H2) *H2 = Eye(v2);
147 static Class Between(
const Class& v1,
const Class& v2, ChartJacobian H1,
148 ChartJacobian H2 = boost::none) {
149 if (H1) *H1 = - Eye(v1);
150 if (H2) *H2 = Eye(v2);
154 static Class Inverse(
const Class& v, ChartJacobian H) {
218 static void Print(Scalar m,
const std::string& str =
"") {
221 static bool Equals(Scalar v1, Scalar v2,
double tol = 1e-8) {
222 return std::abs(v1 - v2) < tol;
229 static Scalar Identity() {
return 0;}
234 typedef Scalar ManifoldType;
235 enum { dimension = 1 };
236 typedef Eigen::Matrix<double, 1, 1> TangentVector;
239 static TangentVector Local(Scalar origin, Scalar other,
240 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
241 if (H1) (*H1)[0] = -1.0;
242 if (H2) (*H2)[0] = 1.0;
243 TangentVector result;
244 result(0) = other - origin;
248 static Scalar Retract(Scalar origin,
const TangentVector& v,
249 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
250 if (H1) (*H1)[0] = 1.0;
251 if (H2) (*H2)[0] = 1.0;
252 return origin + v[0];
258 static TangentVector Logmap(Scalar m, ChartJacobian H = boost::none) {
259 if (H) (*H)[0] = 1.0;
263 static Scalar Expmap(
const TangentVector& v, ChartJacobian H = boost::none) {
264 if (H) (*H)[0] = 1.0;
283struct traits<Eigen::Matrix<double, M, N, Options, MaxRows, MaxCols> > :
285 Eigen::Matrix<double, M, N, Options, MaxRows, MaxCols>, M * N> {
288 typedef Eigen::Matrix<double, M, N, Options, MaxRows, MaxCols> Fixed;
292 static void Print(
const Fixed& m,
const std::string& str =
"") {
295 static bool Equals(
const Fixed& v1,
const Fixed& v2,
double tol = 1e-8) {
303 static Fixed Identity() {
return Fixed::Zero();}
308 enum { dimension = M*N};
309 typedef Fixed ManifoldType;
310 typedef Eigen::Matrix<double, dimension, 1> TangentVector;
311 typedef Eigen::Matrix<double, dimension, dimension> Jacobian;
314 static TangentVector Local(
const Fixed& origin,
const Fixed& other,
315 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
316 if (H1) (*H1) = -Jacobian::Identity();
317 if (H2) (*H2) = Jacobian::Identity();
318 TangentVector result;
319 Eigen::Map<Fixed>(result.data()) = other - origin;
323 static Fixed Retract(
const Fixed& origin,
const TangentVector& v,
324 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
325 if (H1) (*H1) = Jacobian::Identity();
326 if (H2) (*H2) = Jacobian::Identity();
327 return origin + Eigen::Map<const Fixed>(v.data());
333 static TangentVector Logmap(
const Fixed& m, ChartJacobian H = boost::none) {
334 if (H) *H = Jacobian::Identity();
335 TangentVector result;
336 Eigen::Map<Fixed>(result.data()) = m;
340 static Fixed Expmap(
const TangentVector& v, ChartJacobian H = boost::none) {
343 if (H) *H = Jacobian::Identity();
344 return m + Eigen::Map<const Fixed>(v.data());
357 typedef Eigen::Matrix<double, M, N, Options, MaxRows, MaxCols> Dynamic;
361 static void Print(
const Dynamic& m,
const std::string& str =
"") {
364 static bool Equals(
const Dynamic& v1,
const Dynamic& v2,
373 static Dynamic Identity() {
374 throw std::runtime_error(
"Identity not defined for dynamic types");
380 enum { dimension = Eigen::Dynamic };
381 typedef Eigen::VectorXd TangentVector;
382 typedef Eigen::MatrixXd Jacobian;
384 typedef Dynamic ManifoldType;
386 static int GetDimension(
const Dynamic& m) {
387 return m.rows() * m.cols();
390 static Jacobian Eye(
const Dynamic& m) {
391 int dim = GetDimension(m);
392 return Eigen::Matrix<double, dimension, dimension>::Identity(dim, dim);
395 static TangentVector Local(
const Dynamic& m,
const Dynamic& other,
396 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
397 if (H1) *H1 = -Eye(m);
398 if (H2) *H2 = Eye(m);
399 TangentVector v(GetDimension(m));
400 Eigen::Map<Dynamic>(v.data(), m.rows(), m.cols()) = other - m;
404 static Dynamic Retract(
const Dynamic& m,
const TangentVector& v,
405 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
406 if (H1) *H1 = Eye(m);
407 if (H2) *H2 = Eye(m);
408 return m + Eigen::Map<const Dynamic>(v.data(), m.rows(), m.cols());
414 static TangentVector Logmap(
const Dynamic& m, ChartJacobian H = boost::none) {
416 TangentVector result(GetDimension(m));
417 Eigen::Map<Dynamic>(result.data(), m.cols(), m.rows()) = m;
421 static Dynamic Expmap(
const TangentVector& , ChartJacobian H = boost::none) {
422 static_cast<void>(H);
423 throw std::runtime_error(
"Expmap not defined for dynamic types");
426 static Dynamic Inverse(
const Dynamic& m, ChartJacobian H = boost::none) {
431 static Dynamic Compose(
const Dynamic& v1,
const Dynamic& v2,
432 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
433 if (H1) *H1 = Eye(v1);
434 if (H2) *H2 = Eye(v1);
438 static Dynamic Between(
const Dynamic& v1,
const Dynamic& v2,
439 ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
440 if (H1) *H1 = -Eye(v1);
441 if (H2) *H2 = Eye(v1);
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:156