#include#include using namespace Eigen; int main() { Vector3f v(1.0f, 2.0f, 3.0f); std::cout << "Original vector: " << v.transpose() << std::endl; v.normalize(); std::cout << "Normalized vector: " << v.transpose() << std::endl; return 0; }
Original vector: 1 2 3 Normalized vector: 0.267261 0.534522 0.801784
#include#include using namespace Eigen; int main() { Vector3f v(0.0f, 0.0f, 0.0f); std::cout << "Original vector: " << v.transpose() << std::endl; v.normalize(); std::cout << "Normalized vector: " << v.transpose() << std::endl; return 0; }
Original vector: 0 0 0 Normalized vector: 0 0 0In this example, we initialize a `Vector3f` with all zeros and then normalize it using the `normalize()` function. The output shows that the length of the normalized vector is zero. Eigen is a header-only library and does not require linking.