#includeEigen::Vector3f v1(1.0f, 2.0f, 3.0f); Eigen::Vector3f v2(4.0f, 5.0f, 6.0f); Eigen::Vector3f v3 = v1 + v2; // prints 5 7 9 std::cout << v3.x() << " " << v3.y() << " " << v3.z() << std::endl;
#includeThis example creates two Vector3f objects and computes their cross product to get a third Vector3f object. It then prints out the components of the third vector. The package library used here is Eigen, a C++ template library for linear algebra.Eigen::Vector3f v1(1.0f, 2.0f, 3.0f); Eigen::Vector3f v2(4.0f, 5.0f, 6.0f); Eigen::Vector3f v3 = v1.cross(v2); // prints -3 6 -3 std::cout << v3.x() << " " << v3.y() << " " << v3.z() << std::endl;