C++: Eigen::Vector2d - How to Access X and Y Values

Date: 2016-01-30 |

**Problem: **I have a std::vectorEigen::Vector2d variable storing a bunch of points. How do I access the X and Y values of each of these points?

**Solution: **Vector2d takes in a binary value and returns the X or Y value respectively.

double x = aVector(0);

double y = aVector(1);

Similarly, in order to change these values you can:

aVector(0) += 50;

aVector(1) -= 100;

Want more like this?

The best / easiest way to support my work is by subscribing for future updates and sharing with your network.