|
GeometryLib
C++20 3D geometry library
|
GeometryLib is a C++20 3D geometry library built with CMake. It provides analytic geometry primitives — points, vectors, lines, rays, and planes — a bounded shapes layer — segments, triangles, circles, and axis-aligned bounding boxes — and a spatial query layer covering intersection, parallelism, projection, and distance operations. The API is clean, well-tested, and uses scale-independent floating-point comparisons throughout.
The project exports an installable library target (GeometryLib::Geometry), ships CMake package configuration files for downstream find_package consumers, and uses GoogleTest for unit testing.
The documentation is published automatically at: https://psiridis.github.io/GeometryLib/
It is regenerated on every push to main via the GitHub Actions workflow in .github/workflows/docs.yml.
To build the docs locally:
Notes:
ctest is bundled with CMake and is used to run the test suite.The recommended workflow is to use the presets defined in CMakePresets.json.
The debug preset configures the project in build-debug, enables tests, and sets the install prefix to install/ in the source tree.
The release preset configures the project in build-release and disables tests.
The asan preset configures the project in build-asan, enables tests, and adds AddressSanitizer flags.
If you change CMakeLists.txt, presets, or files included from CMake, rerun the configure step before building:
The install rules export the library target, public headers, and package configuration files.
For release:
By default, the presets install into:
Installed package files are placed under:
Tests are enabled in the debug and asan presets and are built into a single executable named geometry_tests.
The debug test preset already enables output on failure.
If CTest reports geometry_tests_NOT_BUILT, reconfigure and rebuild the target:
After installation, consumers can use the exported package configuration.
If GeometryLib is installed in a non-standard location, point CMake at the install prefix:
cmake/GeometrySources.cmake.cmake/GeometryTestSources.cmake.BUILD_TESTING is enabled.GeometryLib::Geometry.GEOM_ASSERT(condition) fires before every throw in debug builds, providing an early abort with file and line info. Both mechanisms remain active — the assert for development, the throw for release-time error handling by callers.almost_equal(a, b) from src/utils/numerical_utils.hpp. Shared tolerance constants k_abs_eps (1e-12) and k_rel_eps (1e-9) are defined there and used consistently across all modules. All threshold checks in the query layer are scale-independent (squared ratios, no raw absolute distances). safe_acos(x) clamps its argument to [-1, 1] before calling std::acos to prevent NaN from floating-point rounding.