homog2d library
homog2d

Current test status:

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.

showcase1.gif
showcase1

(see other demos here)

Short preview:

{C++}
#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]
}

TRYME

Try the above snippet online here, or on your own Debian-style Linux box:

$ sudo apt install build-essential
$ wget https://raw.githubusercontent.com/skramm/homog2d/master/homog2d.hpp
$ wget https://raw.githubusercontent.com/skramm/homog2d/master/misc/tryme.cpp
$ g++ tryme.cpp
$ ./a.out

will print:

[7,8]

(Depending on your GCC version, you might need to add --std=c++17 to the compiler call above.)

TRYME2:

A slightly more significant file is available here, try this:

$ wget https://raw.githubusercontent.com/skramm/homog2d/master/misc/tryme2.cpp
$ g++ tryme2.cpp
$ ./a.out > tryme2.svg

It will generate this Svg file:

tryme2.svg
tryme2

News

(see history for more)

Details

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.