A single-file header-only C++ library dedicated to handling 2D lines, points and homographies (2D planar transformations), using internally homogeneous coordinates. Also handles other geometric primitives, see full manual.
(see other demos here)
- Language: C++14
- Home: https://github.com/skramm/homog2d
- Usage: just fetch the file
homog2d.hpp
, put it somewhere, and "#include" it in your source file. No build! - Status: beta
- Author: Sebastien Kramm, [email protected]
- Licence: MPLv2
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]
}
- 2022-11-23: fresh 2.9 release, lots of new features, see https://github.com/skramm/homog2d/releases
- 2022-09-23: passed the 1000 unit tests threshold (with
$ make test -j4 USE_TINYXML2=Y USE_OPENCV=Y
) - 2022-08-30: added SVG import
- 2022-08-02: 2.8 release
- 2022-05-18: 2.7 release
(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
-
Reference: once downloaded, enter
$ make doc
(requires Doxygen). -
A test file is provided, needs Catch. 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:
- basic primitives: points, lines, segments, circles, rectangles, polygons, ellipse,
- planar transformation of any of these (rotation, translation, ...),
- computing of intersection points between these,
- easy binding with other libs,
- ...
-
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 function whose implementation requires external code. The images are drawn using a third-party library, but it is not needed to use this library.
(*): Except for some additional features, see manual.