How would you build a Point class on top of an Eigen::Vector2f? I want to do something like...
Point p0(1, 2);
Point p1(3, 4);
p0.x += p0.y;
p1 += p0;
cout << p1.transpose() << endl;
I basically need to name the elements of the vector so I can refer to them as x, y, but I still want all the linear algebra from Eigen
to work. Kind of like a union in C. Do I have to build a wrapper around the Eigen::Vector2f
that forwards all the math operators to Eigen
?
This is just a simple example of what I need. In reality, I have long state vectors composed of named variables that I want to pack into Eigen::VectorXd
's and do linear algebra on. I would like a class called StateVector
that looks like an Eigen::Vector
when I do math to it, but where I can manipulate the member variables by name.