Jackalope / jmath (public) (License: GPLv3 or later) (since 2018-10-11) (hash sha1)
C++ conxstexpr template Math library with:
- multidimensional vectors and matrices
- geometry primitives with projection, distance and intersection functions
- coordinate systems conversions
- some routines

Depends on GCE-math C++ library as git submodule.

Used with clang (version 9 or 10) and gcc (version 9).
Written with C++17.
List of commits:
Subject Hash Author Date (UTC)
distance between 2 vectors and intersection line with plane 1620677672179226ea92affb5e3dc600cd3fa133 jp.larry 2020-01-05 03:22:56
2D vector rotate function 049eae7f349cf44bde666b66684a47c8bb4f1300 jp.larry 2020-01-01 05:09:07
removed nodiscard from matrix *= operator and removed redundant function rotate(axis) 0dea084c205202125acfe390a248be61c962d393 jp.larry 2020-01-01 03:09:48
rafactoring update, matrix multiplication now works in different way 2f2e01d80896cd96428a9c9394382e6f040f92fb jp.larry 2019-12-31 11:00:01
round_down function 672a293659a39e29be0d84f28801cf2718070f10 Jackalope 2019-12-28 03:02:03
migw warning solved 80dec7906c5fe2dc026d6774fd526df2ded049cc Jackalope 2019-12-21 10:22:55
refactoring 8b9c8aef3bcbbe3a3a72160eacd15b2d8397524c jp.larry 2019-12-19 08:10:49
lookat and projection functions refactoring f37008f4ad0e4501e89a6a26b4270bc5d6080578 jp.larry 2019-12-16 10:58:53
gcem correct include 03e0350e04d3e1b2c9e7d4f58ef473ce9b5cf319 Your Name 2019-11-27 04:30:39
changed directories layout abcc3ff61e8246f0519498b755bfe23877626144 Your Name 2019-11-26 22:52:02
CMakeLists.txt added 41ddc92280ce3969f8b3f16efce7e63c8c70425a Your Name 2019-11-12 10:32:19
removed excess definition 67b8131470fbbf0d87f2f51cea6326fcdab8d180 Your Name 2019-07-07 12:24:10
gcem updated ff3d073843c2f3a153de930a3651ad8e02c1b7d1 jp.larry 2019-06-19 10:59:53
new functions 46561c6e97aa1ba2d0c41a19ba1977b0427b5f4b Your Name 2019-05-07 05:42:45
new functions 61e3c490daf394f07a4b9de2640d9e1b42fc2dd1 Your Name 2019-05-05 11:28:57
pragma removed 5843f3d68f0d3c08d5be7d16ef8c05db5bceda89 jp.larry 2019-05-01 12:31:57
uint replaced with unsigned int bbde30ca5f66601143ed8862aded9da0cd3aadf8 Your Name 2019-04-30 23:30:19
New enums for vector subscription (X, Y, Z, W, U, V indices) 760dc000f5349f72f8c73330801d1986c46dbb49 jp.larry 2019-04-29 10:43:53
new vector function 570b1dab1163d43426d70048a7ed51162127774e jp.larry 2019-04-26 04:45:13
new functions all vector summ, all vector equal to value ... a47df1be3233abb5e6e2f479b24725bb474cc483 jp.larry 2019-04-25 04:04:26
Commit 1620677672179226ea92affb5e3dc600cd3fa133 - distance between 2 vectors and intersection line with plane
Author: jp.larry
Author date (UTC): 2020-01-05 03:22
Committer name: jp.larry
Committer date (UTC): 2020-01-05 03:22
Parent(s): 049eae7f349cf44bde666b66684a47c8bb4f1300
Signing key:
Tree: 0b70053a234f733f06dba8fecd66be93eae7a293
File Lines added Lines deleted
include/math/matrix/base.hpp 5 18
include/math/vector/vector_functions.h 13 0
File include/math/matrix/base.hpp changed (mode: 100644) (index f45d03a..98026a6)
... ... namespace math
27 27 m._[i][j] = type(0); m._[i][j] = type(0);
28 28 return m; return m;
29 29 } }
30
31 30 MATR_T template<int other_size, int other_vector_size, typename other_t> MATR_T template<int other_size, int other_vector_size, typename other_t>
32 31 constexpr inline MATRIX& constexpr inline MATRIX&
33 32 MATRIX::operator*=(const matrix<other_size, other_vector_size, other_t>& m) { MATRIX::operator*=(const matrix<other_size, other_vector_size, other_t>& m) {
 
... ... namespace math
46 45 m._[i][j] += _[i][k] * other._[k][j]; m._[i][j] += _[i][k] * other._[k][j];
47 46 return m; return m;
48 47 } }
49 /*template<typename type> template<typename other_t> inline
50 matrix<4, 4, type> matrix<4, 4, type>::operator * (const matrix<4, 4, other_t>& other) const
51 {
52 return {_[0] * other[0][0] + _[1] * other[0][1] + _[2] * other[0][2] + _[3] * other[0][3],
53 _[0] * other[1][0] + _[1] * other[1][1] + _[2] * other[1][2] + _[3] * other[1][3],
54 _[0] * other[2][0] + _[1] * other[2][1] + _[2] * other[2][2] + _[3] * other[2][3],
55 _[0] * other[3][0] + _[1] * other[3][1] + _[2] * other[3][2] + _[3] * other[3][3] };
56 }*/
57
58 48 MATR_T template<typename other_t> MATR_T template<typename other_t>
59 49 [[nodiscard]] constexpr inline typename MATRIX::vector [[nodiscard]] constexpr inline typename MATRIX::vector
60 MATRIX::operator *(const math::vector<size, other_t>& vec) const {
61 static_assert (size == vector_size);
62 MATRIX::vector result{};
50 MATRIX::operator *(const math::vector<size, other_t>& vec) const
51 {
52 MATRIX::vector v{};
63 53 for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
64 54 for(int k = 0; k < vector_size; k++) for(int k = 0; k < vector_size; k++)
65 result[i] += (*this)[i][k] * vec._[k];
66 return result;
55 v[i] += (*this)[i][k] * vec[k];
56 return v;
67 57 } }
68 58 T_NUMERIC_IMPL MATRIX& MATRIX::operator += (const numeric_t& value) { T_NUMERIC_IMPL MATRIX& MATRIX::operator += (const numeric_t& value) {
69 59 for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
 
... ... namespace math
86 76 #undef MATRIX #undef MATRIX
87 77 #undef MATRIX_OTHER #undef MATRIX_OTHER
88 78 } }
89
90
91
File include/math/vector/vector_functions.h changed (mode: 100644) (index 6379980..b42b9b1)
... ... namespace math
34 34 return (l + r) / two<T>; return (l + r) / two<T>;
35 35 } }
36 36
37 template<typename T> [[nodiscard]] constexpr inline
38 T distance(const vector<3,T> &point1, const vector<3,T> &point2) {
39 return (point2 - point1).length();
40 }
41
37 42 template<typename T> [[nodiscard]] constexpr inline template<typename T> [[nodiscard]] constexpr inline
38 43 T distance(const vector<4,T> &plane, const vector<3,T> &point) { T distance(const vector<4,T> &plane, const vector<3,T> &point) {
39 44 auto normal = plane.template part<0,3>(); auto normal = plane.template part<0,3>();
 
... ... namespace math
49 54 vector<SIZE,T> normalize(const vector<SIZE, T> &v) { vector<SIZE,T> normalize(const vector<SIZE, T> &v) {
50 55 return v.normalized(); return v.normalized();
51 56 } }
57
58 template<typename T> [[nodiscard]] constexpr inline
59 vector<3,T> intersection(const vector<4,T> &plane, const vector<3,T> &ray,
60 const vector<3,T> &ray_point) {
61 auto &normal = plane.template part<0,3>();
62 float scale = (plane.w - dot(normal, ray_point)) / dot(normal, ray);
63 return ray_point + ray * scale;
64 }
52 65 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/Jackalope/jmath

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/Jackalope/jmath

Clone this repository using git:
git clone git://git.rocketgit.com/user/Jackalope/jmath

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main