I'm calling slerp()
from the Eigen libary as follows:
Eigen::MatrixXf Rtime = (Eigen::Quaternionf::Identity().slerp(timer, quarts[i])).toRotationMatrix();
where timer
is a float and quarts is declared as
std::vector<Eigen::Quaternionf> quarts;
This call to slerp only causes a Read Access Violation sometimes (about 50% of the time) , which confuses me.
Looking at the stack frame,
I can see that the code reaches
Eigen::internal::pload
until it breaks.
Generally I'd think that my indices are incorrect but it crashes even when
i = 0
and quarts.size() = 1
. I declare the only quaternion in the vector:
Eigen::Matrix3f rotMatrix;
rotMatrix = U * V;
Eigen::Quaternionf temp;
temp = rotMatrix;
quarts.push_back(temp);
where U
and V
come from a computation of Singular Value Decomposition, so maybe there's something wrong with the way I declare the quaternion? Or storing it in a vector in some way affects it? I'm not sure.
The problem is that Quaternionf
requires 16 bytes alignment that is not guaranteed by std::vector
. More details there. The solutions are either to use an aligned allocator, e.g.:
std::vector<Quaternionf,Eigen::aligned_allocator<Quaternionf>> quats;
or to use non-aligned quaternions within the vector:
std::vector<Quaternion<float,Eigen::DontAlign>> quats;