Registered Member
|
I just started to use Eigen and found it very powerful. So good I want to use it as base class form my c++ geometry classes.
I would like to have a CGeoVector3D class derive directly from Eigen::Matrix<Real, 1, 3> and take advantage Eigen's neat operator overloading. The problem is I tried it and it does not inherit the assignment operator and constructor. Is there a document where this is explained? B. Araujo. |
Registered Member
|
OK. I think I figured it out. I had a look at:
http://www.cs.cornell.edu/courses/CS663 ... ource.html The code: #pragma once #include <Eigen/Dense> template <typename Real> struct CGeoVertex3 : public Eigen::Matrix<Real, 3, 1> { public: typedef Eigen::Matrix<Real, 3, 1> Base; inline CGeoVertex3(Real value = (Real) 0) { setConstant(value); } inline CGeoVertex3(const Real x, const Real y, const Real z) : Base(x, y, z) { } template <typename Derived> inline CGeoVertex3(const Eigen::MatrixBase<Derived>& p) : Base(p) { } template <typename Derived> CGeoVertex3 &operator=(const Eigen::MatrixBase<Derived>& p) { this->Base::operator=(p); return *this; } }; |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]