I came across the problem that I want to convert from a std::vector<Eigen::Vector3d>
to a std::vector<Eigen::Vector3f>
. I was wondering if there is a solution where I dont have to iterate over the points.
// mapping using iteration
std::vector< Eigen::Vector3d> tf{ {1,1,1},{1,1,1},{1,1,1} };
std::vector< Eigen::Vector3f> tf2;
tf2.reserve(tf.size());
std::transform(tf.begin(), tf.end(), std::back_inserter(tf2), [](const Eigen::Vector3d& p) {
return p.cast<float>();
});
I tried some things like tf.data()
and tried to cast that, but I didnt found a solution. I also looked into Eigen::Map<>
class, but didnt really find a solution.