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

Customizing Eigen question

Tags: None
(comma "," separated)
alexanderc
Registered Member
Posts
6
Karma
0

Customizing Eigen question

Sun Jun 08, 2014 2:57 pm
Hi I am new to Eigen,

I am trying to make it compatible with my game engine.
I am looking for advice if this is the most efficient way of extending matrices.
I read http://eigen.tuxfamily.org/dox/TopicCustomizingEigen.html

This is my approach to lerp:

Code: Select all
template<typename T>
T lerp(Scalar scalar, const T& r)
{ return (*this) + (r - (*this)) * scalar; }


If I try it less general I get some conversion errors:

Code: Select all
template<typename T>
MatrixBase<T> lerp(Scalar scalar, const MatrixBase<T>& r)
{ return (*this) + (r - (*this)) * scalar; }


I also tried wrapping some of the functions to use the same names as I am already using like dot to dotProduct.

Code: Select all
template<typename T>
inline RealScalar dotProduct(const T& rhs) const { return (*this).dot(rhs); }


Can you give a few more examples how to properly add new functions ,wrapping existing and add new conversions.

Thanks in advance,

Alex
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Customizing Eigen question

Sun Jun 08, 2014 8:49 pm
You cannot return a MatrixBase<T> object, it is like an abstract base class, so you cannot create an object of such a type. Make lerp return a PlainObject. This is a typedef to the right Matrix<> type. It is defined in MatrixBase so you can directly use it.
alexanderc
Registered Member
Posts
6
Karma
0

Re: Customizing Eigen question

Sun Jun 08, 2014 11:44 pm
Thank you for your answer :)


Bookmarks



Who is online

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