Closed michaelpantic closed 5 years ago
Test PASSed.
Test PASSed.
Test PASSed.
Decided to extend implementation to 2D points/vectors, as I need that too, so wait with review.
Update: Done. Ready for review.
Test PASSed.
Test PASSed.
Test PASSed.
Test PASSed.
Test PASSed.
Test PASSed.
@hermannsblum thanks for reviewing! merging...
More PRs! Sorry :-) Warning: Code in this PR is made highly generic and solves a very technical problem but will increase code readability for other functions a lot. Code readability of this part though...well I tried my best.
Content of PR: Custom data type that allows us to write functions that consume/return cgal::Vector/Eigen::Vector3d/cgal::Point at the same time without ever having to explicitly convert/cast. Same applies for cgal::Vector_2/Eigen::Vector2d/cgal::Point_2, depending on template parameter N.
This PR can be merged independently of the others.
See following code comment and/or tests in file test_cgal_eigen_adapter.cpp for example.
Text from code comment:
This header-only library provides functionality to design functions such that they automatically accept eigen and cgal vectors without templates/overloading and the like. Makes Eigen::Vector3d / cgal::Vector_3 / cgal::Point_3 interchangeable.
Examples:
You want a function that accepts a Vector3 (regardless of eigen/cgal):
Signature:
void yourFunction(Vector3In vec)
Usage: Whenever you assign vec to a cgal or eigen vector, it gets converted transparently.
Inside the function: e.g.
Eigen::Vector3d test = vec;
orcgal::Vector test2 = vec;
Calling the function: yourFunction(test) (where test is of type Eigen::Vector3d o cgal::Vector/Point, doesn't matter)
You want a function that returns a Vector3 that can be assigned to eigen / cgal:
Signature:
Vector3Return yourFunction()
Usage:
Eigen::Vector3d test = yourFunction();
orcgal::Vector test2 = yourFunction();
Inside function: return Eigen::Vector3d(...) or cgal::Vector(...) or cgal::Point(...)
You want a function with a Vector3 as output parameter:
void yourFunction(Vector3Out vec_out)
yourFunction(&test)
, where test is of type Eigen::Vector3d or cgal::Vector or cgal::Point)Of course any combination of the above 3 is also valid.
Example from code: See public methods from e.g. https://github.com/ethz-asl/cad-percept/blob/9215a98a04d1ea2d3618a6ad773060548b2b913a/cpt_planning/include/cpt_planning/coordinates/barycentric.h#L15
Defines barycentric coordinates for 2d and 3d types and allows usage and return of any mixture of cgal/eigen types with only 4 methods defined !