This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Extend eigen: add new class

Tags: None
(comma "," separated)
arennuit
Registered Member
Posts
28
Karma
0

Extend eigen: add new class

Thu Nov 28, 2013 3:46 pm
Hello,

I would like to extend Eigen in such a way to support "Frames". A frame is a 7D vector containing a quaternion and a vector3: hence it is a compact representation of an homogeneous matrix (only much less redundant).

I can see three approaches in order to define this new eigen type:
1) Create a Frame class outside of the Eigen framework which contains both a quaternion and a Vector3
- This class would not use expression templates
- This will work and is easy to put in place but then I loose all the flexibility of Eigen when using class Frame
+ As it is a "normal" class and not a template a-la Eigen
2) Create a new standalone Frame class with heavy templetization a-la Eigen
- This requires to understand the heart of Eigen (I must admit I am far from understanding all the subtleties of Eigen's inner code)
- This is heavy to put in place
- I am not sure how to integrate this to Eigen
3) Typedef Matrix<float, 7, 1> Frame
- Specialize the required templates for new type Frame using EIGEN_MATRIXBASE_PLUGIN
+ Will this work? -> what will happen when I call a templated method specialized for Frame on a Matrix<float, 7, 1> (not a Frame), will it call the method specialized for Frame? --> of course this is not what I want...
- Add the relevant new functions using EIGEN_MATRIXBASE_PLUGIN

What would you recomment in my case?

Thanks!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Extend eigen: add new class  Topic is solved

Thu Nov 28, 2013 9:07 pm
Expression template for 3D transformations is not very important because 1) the main operation we perform on transformation is to apply it to vector(s), and 2) for small fixed size objects, returning by value is not a problem because the temporaries will be very easily optimized away by the compiler. So I'd not bother much and start with:
Code: Select all
template<typename Scalar>
class Frame {
Quaternion<Scalar> m_orientation;
Matrix<Scalar,3,1> m_position;
};


and add all the operators you need and make them return by value.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]