On Wed, Oct 21, 2009 at 2:24 PM, Mathieu Gautier
<mathieu.gautier@xxxxxx> wrote:
Hi,
I want to implement a class which hold both a quaternion and a vector3 to discribe a position of a frame in respect to an other frame (Something similar to Frame in KDL). For some historic reason, the memory layout must be a continuous array of scalar (Scalar[7]), the 3 first scalars are the vector3 and the other are the quaternion. Besides I have to interface this structure with other libraries which return an array of 7 scalars. I also have to map array of 4 scalars into the Quaternion class.
I though of something like that :
template<typename _Scalars>
struct Frame {
_Scalars[7] data;
Map<Matrix<3,1,_Scalars>> v;
Map<Quaternion<_Scalars>> q;
};
and setting the Map accordingly. However, there's no such concept of Map for the Quaternion class or RotationBase.
So, I modified the Quaternion class to use either a Matrix<Scalar,4,1> to store the quaternion coefficients or a Map<Matrix<Scalar,4,1>> to map an array of scalars. I added a argument to the template prototype of the quaternion class which I call StorageType which is either the Matrix or Map<Matrix>.
Since I have almost no experience with Eigen, I don't know if it's the better choice and if it could cause alignement issues. I have attached my modifications as a patch. This implementation may be incomplete.
So, to summarize, the Frame class would be:
template<typename _Scalars>
struct Frame {
_Scalars[7] data;
Map<Matrix<3,1,_Scalars>> v;
QuaternionMap<_Scalars> q;
};
where v is a mapping of data and q a mapping of data+3.
note that here sizeof(Frame) wont be 7 * sizeof(_Scalars), so I'd rather make v and q member functions returning Mapped objects.
--
Mathieu Gautier