项目作者: philsupertramp

项目描述 :
C++ library implementing game related math
高级语言: C++
项目地址: git://github.com/philsupertramp/game-math.git
创建时间: 2020-10-20T09:17:31Z
项目社区:https://github.com/philsupertramp/game-math

开源协议:MIT License

下载


game-math

Tests CodeFactor

Mathematical library for game developers.
The library contains necessary elements of Matrix Algebra to enable working in 2D and 3D space.

Current feature support

  • Math:
    • 2,3,4-dimensional Matrix/Vector algebra (math.h)
    • Matrix class with many implemented opterations
  • Game specific:
    • 2D/3D Transformation utils to generate View/Transformation matrices in a 2D view space (utils.h)
  • Sorting (insertion sort)
  • Random Number Generator
  • String formatting

Benchmarks

see /benchmarks/README.md

  1. Matrix<int>:
  2. finished computation with 9 elements and 5000000 * operations. elapsed time: 0.160372s
  3. finished computation with 9 elements and 5000000 # operations. elapsed time: 0.0172873s
  4. finished computation with 9 elements and 5000000 + operations. elapsed time: 0.145237s
  5. mat3<int>:
  6. finished computation with 9 elements and 5000000 * operations. elapsed time: 4.3e-08s
  7. finished computation with 9 elements and 5000000 + operations. elapsed time: 5e-08s
  8. Matrix<double>:
  9. finished computation with 9 elements and 5000000 * operations. elapsed time: 0.132516s
  10. finished computation with 9 elements and 5000000 # operations. elapsed time: 0.00899579s
  11. finished computation with 9 elements and 5000000 + operations. elapsed time: 0.152282s
  12. mat3<double>:
  13. finished computation with 9 elements and 5000000 * operations. elapsed time: 5.2e-08s
  14. finished computation with 9 elements and 5000000 + operations. elapsed time: 5e-08s
  15. Matrix<float>:
  16. finished computation with 9 elements and 5000000 * operations. elapsed time: 0.186274s
  17. finished computation with 9 elements and 5000000 # operations. elapsed time: 0.00887903s
  18. finished computation with 9 elements and 5000000 + operations. elapsed time: 0.146145s
  19. mat3<float>:
  20. finished computation with 9 elements and 5000000 * operations. elapsed time: 7.1e-08s
  21. finished computation with 9 elements and 5000000 + operations. elapsed time: 8e-08s

Build requirements

gcc, cmake, clang

Installation

  1. Download repository
    git clone git@github.com:/philsupertramp/game-math

  2. Integration into your project

Only CMake fully tested

cmake:

in your CMakeLists.txt add

  1. link_libraries(math-lib)
  2. include_directories(math/include)

Usage

After linking the library correctly one is able to include
the main header file math.h

  1. #include <math/math.h>

Although one can explicitly include parts

  1. #include <math/vec/vec2.h>

Extensions

Currently there are two different implementations
of matrices/vectors

Implementation 1)

Game dev oriented. 2, 3 and 4 dimensional vector/matrix
implementations.
Tightly packed data to allow minimal memory usage.
see ./include/math/vec and ./include/math/mat
for implementation details.

Implementation 2)

Matrix<T> (see ./include/math/Matrix.h) represents a m x n-Matrix of data of type T

a specific data science and numerics implementation.
Capable of Matrix-Vector and Matrix-Multiplication, it also contains
data science specific algorithms and statistical methods.

Development

Feel free to contribute to the project!

How to contribute

  • first time contributors
    • fork the project
    • create a PR based on your repository
  • known contributors
    • create PR based on master branch

NOTE: please run make lint prior to submitting your code!
This requires clang-format>=11.0.0

License

The project is under MIT-License see LICENSE for more

Acknowledgements