Skip to content
/ homog2d Public

C++ 2D geometry library, handles points, lines, polylines, planar transformations (and other primitives), using homogeneous coordinates. Provided with complete manual and samples.

License

Notifications You must be signed in to change notification settings

skramm/homog2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

homog2d

Current test status: GH actions build status

License: MPLv2

File size in bytes on master

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

(see other demos here)

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]
}

News

(see history for more)

Details

  • 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:

    • Usage simplicity, max flexibility
    • No dependency (*)
    • Modern C++, using policy-based design, tag dispatching, sfinae, ...
    • Direct bindings with other libraries (OpenCv, Boost Geometry) (optional)
  • 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,
    • enclosing determination
    • ...
  • Related libraries:

    • CGAL, the reference computational geometry library.
    • Boost Geometry, a highly generic library with some overlapping features (but quite harder to use)
    • Opencv, the reference CV library, much more algorithms, but no direct support for homogeneous geometry.
    • Wykobi, has much more computational geometry features but no direct support for homogeneous geometry.

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.

About

C++ 2D geometry library, handles points, lines, polylines, planar transformations (and other primitives), using homogeneous coordinates. Provided with complete manual and samples.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages