I am stumped on how to create a simple transformation matrix.
I have the following C++ code:
static constexpr float pos_scale = 2 * size / iside;
static constexpr std::array<float, 2> pos_translation = { -size, -size };
Unfortunately, the pos_translation needs to be a std::array because you can't make an Eigen::Vector2f constexpr.
Then I have a vector:
Vector2i xy;
That will be filled with some data.
I want to convert xy to a Vector2f by converting it to homogeneous coordinates, multiplying it with a transformation matrix and then dropping the homogeneous coordinates again.
The transformation matrix is declared as
Matrix3f xy_to_pos;
at least, I think that is the right type to use?
My question is, how can I initialize xy_to_pos from pos_scale (which has to be applied first: first the scale then the translation) and pos_translation?
And once I have xy_to_pos how would I use it to convert xy to Vector2f pos?
I tried all kinds of things, like
Matrix3f xy_to_pos = Matrix3f::Identity() * Eigen::Scaling(pos_scale) * Eigen::Translation2f(pos_translation[0], pos_translation[1]);
but nothing compiles, and the compile errors don't help. I Googled for this too of course, but couldn't find an example that helped.