UsingVector4fForVector3fOperations

From Eigen
Jump to: navigation, search

In many cases, one needs to use the Vector3f class (in 3D codes, for instance). However, since it is not a multiple of 16 bytes, you do not get the benefit of vectorization. However, in certain instances, you may be able to simply use a Vector4f class with the last component set to zero to use vectorization. For component wise operations such as add, subtract and multiply, you can of course blissfully ignore the last component. However, for dot and cross products and normalization operations, you will need to have the w component set to 0.