You must have thought about why we must manually do all the tough mathematical calculations, as it is sometimes very boring. They invented computers to make things easier, did they not?
Well, someone else thought it too, and Eigen the beautiful thing that came out of their mind.
What is Eigen
Eigen has a wide range of usages and can help perform complex mathematical operations. These operations are Dot Product, Cross Product, Vector Addition, Vector Subtraction, Multiplication, and other algebraic operations.
Eigen’s library is extremely useful for people involved in robotics. It makes a lot of complicated tasks possible relatively quickly. It has many applications in robotics and helps perform different operations.
Geometrical Transformations
Eigen’s Geometry Module offers many methods to deal with things like 2D/3D rotations and Projective or Affine Transformations.
Eigen’s Geometry Module offers transformations that are summarised into two broad categories:
Abstract Transformations like Rotations, Translations, and Scaling
Projective or Affine Transformation Matrices
For example
A Transform for an abstract Transformation can be defined as
Transform t(AngleAxis(angle, axis));
You can also try this code with Online C++ Compiler
Rotation Matrices are preferred representations to convert more than a single vector. Quaternion represents a choice for other uses as they are fast, compact, and stable.
Finally, Rotation2D and Angle Axis are suitable for creating other rotation objects.
Notes on Translation and Scaling:
These classes, like AngleAxis, were created to simplify the design and definition of linear matrices and Affine transformations.
However, unlike AngleAxis, which is weak, these classes might still be interested in writing generic and efficient algorithms taking any transformations as input.
Any of the above Transformations can be converted into others of the exact nature or to a more generic type. Here are some examples
The Affine Transformations that are generic are represented by the class called Transform Class. Transform Class is internally a (Dim +1) ^ 2 matrix (here, Dim is the Dimension of the Matrix).
In Eigen’s Geometry Module, Vectors and Points are declared as same; Displacement Vectors from the origin represent all points. As they are the same, the actual points and vectors can be told apart when the transformation is applied.
Apply Transformation to a Point
VectorNf vector1, vector2;
vector2 = t * vector1;
You can also try this code with Online C++ Compiler
It should be noted that in both of the APIs said above. Different transformations can be joined into a single expression, as mentioned in the examples below:
t.pretranslate(..).rotate(..).translate(..).scale(..);
t = Translation_(..) * t * RotationType(..) * Translation_(..) * Scaling(..);
Try and compile by yourself with the help of online C++ Compiler for better understanding.
Frequently Asked Questions
What are some common operations that can be performed using the Eigen Library?
Functions such as the definition of vectors, matrices, and quaternions, along with some mathematical functions such as addition/subtraction of vectors, dot product, and cross product, can also be completed using the Eigen’s Geometry Library.
What are the primary fields where the Eigen Library is used?
The Eigen’s Geometry Library is very useful for Robotics and other real-world applications. Eigen’s Library is used to achieve many algebraic computations quickly.
What are Euler Angles?
Euler Rotations are the set of three angles about which the matrix can be rotated. Euler Angles represent a rotation in three dimensions space as three Euler Angles.
What is OpenGL?
OpenGL is a cross-platform and cross-interface library that renders 2D and 3D vector graphics. The OpenGL API is typically used to interact with the graphics processing unit to achieve hardware-accelerated rendering.
What are Affine Transformations?
Affine transformation is a linear method that preserves mathematical entities such as points, straight lines, and planes. It can also be described as a transformation that preserves co-linearity and distance ratios.
Conclusion
In this article, we briefly discussed what Eigen’s Library is and what its usages are.
We discussed the Geometry Methods/Transformations offered in Eigen (Eigen’s Geometry) at length and how to implement them.
For more information on Eigen and related topics, refer to the following articles: