C++ 2D geometry library, handles points, lines, polylines, planar transformations (and other primitives), using homogeneous coordinates. Provided with complete manual and samples.
A single-file header-only C++ library dedicated to handling 2D lines, points and homographies (2D planar transformations) in Cartesian geometry, using internally homogeneous coordinates. Also handles other geometric primitives, see full manual.
(see other demos here)
homog2d.hpp
, put it somewhere, and "#include" it in your source file. No build!Short preview:
#include "homog2d.hpp"
using namespace h2d;
int main()
{
Line2d l1( Point2d(10,10) ); // a line passing through (0,0) and (10,10)
Line2d l2( Point2d(0,10), Point2d(10,0) ); // a line passing through (0,10) and (10,0)
auto pt = l1 * l2; // intersection point (5,5)
Homogr H(2,3); // a translation matrix
std::cout << H * pt; // prints [7,8]
}
std::variant
, see here
(see history for more)
Install: to install on your machine, copy file homog2d.hpp
somewhere where your compiler can reach it, or $ sudo make install
after cloning repo.
This will copy that file in /usr/local/include
.
Audience: any C++ dev requiring some basic computational geometry, without the burden of large scale framework.
Usage: see full manual, or Doxygen-generated pages online.
Reference: once downloaded, enter $ make doc
(requires Doxygen), or read online.
A test file is provided, needs Catch2.
When installed, run $ make test
(or $ make testall
for testing with all 3 numerical types).
Contributing: at present, the best you can do is testing and bug/issue reporting. Don't hesitate, this is still beta but stable release expected soon.
Rationale:
Geometric features:
Related libraries:
Warning: The images shown in the manual are there just there as an illustration of what the library does, but there is no rendering code included. The library provides drawing functions, that can be used to generate Svg files. An alternative is to use a supported third-party library (Opencv), but the latter is not needed to use this library.
(*): Except for some additional features, see manual.