Eigen::Vector3f u, v;
u(0) = 1.0;
u(1) = 0.0;
u(2) = 0.0;
// Another way of initializing a vector/matrix
v << 0.0, 1.0, 0.0;
cout << "u: " << u.transpose() << endl;
cout << "v: " << v.transpose() << endl;
Eigen::Vector3f w = u.cross(v);
cout << u.transpose() << " cross " << v.transpose() << " = " << w.transpose() << endl;
double dot = u.dot(v);
cout << u.transpose() << " dot " << v.transpose() << " = " << dot << endl;
Eigen::Vector3f uHat = u.normalized(); // Notice that these two now have the
u.normalize(); // same value. Eigen normalizes in place.
double normU = u.norm(); // Note: be careful in performing
double normUHat = uHat.norm(); // A=A.something()! [See "ALIASING" topic in Eigen]
cout << "normU: " << normU << endl;
cout << "normUHat: " << normUHat << endl;
Eigen::Matrix2f m;
m(0, 0) = 3;
m(1, 0) = 2.5;
m(0, 1) = -1;
m(1, 1) = m(1, 0) + m(0, 1);
cout << "\nMatrix m:\n" << m << endl;
// Again, initialize with comma initializer
Eigen::Matrix3f n;
n << 1, 2, 3,
4, 5, 6,
7, 8, 9;
cout << "\nMatrix n:\n" << n << endl;
Eigen::Matrix3f m1 = m + n; // This will fail.
Eigen::Matrix2f m2 = Eigen::Matrix2f::Identity();
Eigen::Matrix2f m3 = m + m2; // This will not.
cout << "\nMatrix m3:\n" << m3 << endl;
A geometry processing framework
More on http://openflipper.org/Documentation/latest/index.html
git clone --recursive https://graphics.rwth-aachen.de:9000/OpenFlipper-Free/OpenFlipper-Free.git
~$ cd /path/to/OpenFlipper-Build/
~$ make
~$ ./Build/OpenFlipper.app/Contents/MacOS/OpenFlipper