Popularity
3.4
Growing
Activity
8.7
Growing
271
16
13

Description

Klein is an implementation of P(R*_{3, 0, 1}), aka 3D Projective Geometric Algebra. It is designed for applications that demand high-throughput (animation libraries, kinematic solvers, etc). In contrast to other GA libraries, Klein does not attempt to generalize the metric or dimensionality of the space. In exchange for this loss of generality, Klein implements the algebraic operations using the full weight of SSE (Streaming SIMD Extensions) for maximum throughput.

Programming language: C++
Tags: Game Engine     Graphics     Math     Scientific Computing     Animation     C++17     Geometry    
Latest version: v2.2.1

Klein alternatives and similar libraries

Based on the "Math" category

  • GLM

    8.7 8.1 L1 Klein VS GLM
    Header-only C++ math library that matches and inter-operates with OpenGL's GLSL math. [MIT]
  • OpenBLAS

    An optimized BLAS library based on GotoBLAS2 1.13 BSD version. [BSD 3-clause] website
  • QuantLib

    A free/open-source library for quantitative finance. [Modified BSD] website
  • CGal

    7.7 9.9 L1 Klein VS CGal
    Collection of efficient and reliable geometric algorithms. [LGPL&GPL]
  • ceres-solver

    C++ library for modeling and solving large complicated nonlinear least squares problems from google. [BSD]
  • Eigen

    A high-level C++ library of template headers for linear algebra, matrix and vector operations, numerical solvers and related algorithms. [MPL2]
  • Vc

    5.5 0.3 L1 Klein VS Vc
    SIMD Vector Classes for C++. [BSD]
  • NT2

    A SIMD-optimized numerical template library that provides an interface with MATLAB-like syntax. [Boost]
  • TinyExpr

    tiny recursive descent expression parser, compiler, and evaluation engine for math expressions
  • linmath.h

    A lean linear math library, aimed at graphics programming. [WTFPL]
  • MIRACL

    A Multiprecision Integer and Rational Arithmetic Cryptographic Library. [AGPL]
  • LibTomMath

    A free open source portable number theoretic multiple-precision integer library written entirely in C. [PublicDomain & WTFPL] website
  • GMTL

    4.0 0.0 L1 Klein VS GMTL
    Graphics Math Template Library is a collection of tools implementing Graphics primitives in generalized ways. [GPL2]
  • ExprTK

    The C++ Mathematical Expression Toolkit Library (ExprTk) is a simple to use, easy to integrate and extremely efficient run-time mathematical expression parser and evaluation engine. [CPL]
  • muparser

    muParser is an extensible high performance math expression parser library written in C++. [MIT]
  • blaze

    high-performance C++ math library for dense and sparse arithmetic. [BSD]
  • Apophenia

    A C library for statistical and scientific computing [GPL2]
  • Boost.Multiprecision

    provides higher-range/precision integer, rational and floating-point types in C++, header-only or with GMP/MPFR/LibTomMath backends. [Boost]
  • safe_numerics

    Replacements to standard numeric types which throw exceptions on errors
  • Wykobi

    A C++ library of efficient, robust and simple to use C++ 2D/3D oriented computational geometry routines. [MIT]
  • cml

    2.1 0.0 L3 Klein VS cml
    free C++ math library for games and graphics. [Boost]
  • Versor

    A (fast) Generic C++ library for Geometric Algebras, including Euclidean, Projective, Conformal, Spacetime (etc).
  • metamath

    metamath is a tiny header-only library. It can be used for symbolic computations on single-variable functions, such as dynamic computations of derivatives.
  • Xerus

    A general purpose library for numerical calculations with higher order tensors, Tensor-Train Decompositions / Matrix Product States and other Tensor Networks
  • Mission : Impossible (AutoDiff)

    A concise C++17 implementation of automatic differentiation (operator overloading)
  • Armadillo

    A high quality C++ linear algebra library, aiming towards a good balance between speed and ease of use. The syntax (API) is deliberately similar to Matlab. [MPL2]
  • GMP

    A C/C++ library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers. [LGPL3 & GPL2]

Do you think we are missing an alternative of Klein or a related project?

Add another 'Math' Library

README

Klein

License: MIT DOI

Build Status Build Status Coverity Status Codacy Badge

๐Ÿ‘‰๐Ÿ‘‰ Project Site ๐Ÿ‘ˆ๐Ÿ‘ˆ

Description

Do you need to do any of the following? Quickly? Really quickly even?

  • Projecting points onto lines, lines to planes, points to planes?
  • Measuring distances and angles between points, lines, and planes?
  • Rotate or translate points, lines, and planes?
  • Perform smooth rigid body transforms? Interpolate them smoothly?
  • Construct lines from points? Planes from points? Planes from a line and a point?
  • Intersect planes to form lines? Intersect a planes and lines to form points?

If so, then Klein is the library for you!

Klein is an implementation of P(R*_{3, 0, 1}), aka 3D Projective Geometric Algebra. It is designed for applications that demand high-throughput (animation libraries, kinematic solvers, etc). In contrast to other GA libraries, Klein does not attempt to generalize the metric or dimensionality of the space. In exchange for this loss of generality, Klein implements the algebraic operations using the full weight of SSE (Streaming SIMD Extensions) for maximum throughput.

Requirements

  • Machine with a processor that supports SSE3 or later (Steam hardware survey reports 100% market penetration)
  • C++11/14/17 compliant compiler (tested with GCC 9.2.1, Clang 9.0.1, and Visual Studio 2019)
  • Optional SSE4.1 support

Usage

You have two options to use Klein in your codebase. First, you can simply copy the contents of the public folder somewhere in your include path. Alternatively, you can include this entire project in your source tree, and using cmake, add_subdirectory(Klein) and link the klein::klein interface target.

In your code, there is a single header to include via #include <klein/klein.hpp>, at which point you can create planes, points, lines, ideal lines, bivectors, motors, directions, and use their operations. Please refer to the project site for the most up-to-date documentation.

Motivation

PGA fully streamlines traditionally used quaternions, and dual-quaternions in a single algebra. Normally, the onus is on the user to perform appropriate casts and ensure signs and memory layout are accounted for. Here, all types are unified within the geometric algebra, and operations such as applying quaternion or dual-quaternions (rotor/motor) to planes, points, and lines make sense. There is a surprising amount of uniformity in the algebra, which enables efficient implementation, a simple API, and reduced code size.

Performance Considerations

It is known that a "better" way to vectorize computation in general is to arrange the data in an SoA layout to avoid unnecessary cross-lane arithmetic or unnecessary shuffling. PGA is unique in that a given PGA multivector has a natural decomposition into 4 blocks of 4 floating-point quantities. For the even sub-algebra (isomorphic to the space of dual-quaternions) also known as the motor algebra, the geometric product can be densely packed and implemented efficiently using SSE.

References

Klein is deeply indebted to several members of the GA community and their work. Beyond the works cited here, the author stands of the shoulders of giants (Felix Klein, Sophus Lie, Arthur Cayley, William Rowan Hamilton, Julius Plรผcker, and William Kingdon Clifford, among others).

[1] Gunn, Charles G. (2019). Course notes Geometric Algebra for Computer Graphics, SIGGRAPH 2019. arXiv link

[2] Steven De Keninck and Charles Gunn. (2019). SIGGRAPH 2019 Geometric Algebra Course. youtube link

[3] Leo Dorst, Daniel Fontijne, Stephen Mann. (2007) Geometric Algebra for Computer Science. Burlington, MA: Morgan Kaufmann Publishers Inc.


*Note that all licence references and agreements mentioned in the Klein README section above are relevant to that project's source code only.