diff --git a/include/detail/math.hpp b/include/detail/math.hpp
deleted file mode 100644
index f5997bf..0000000
--- a/include/detail/math.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- This file is a part of the rexy/r0nk/atlas project
- Copyright (C) 2020 rexy712
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-
-#ifndef REXY_DETAIL_MATH_HPP
-#define REXY_DETAIL_MATH_HPP
-
-namespace math{
-
- namespace detail{
- struct zero_initialize_t{};
- struct no_initialize_t{};
- struct id_initialize_t{};
-
- }
-
- static inline constexpr detail::zero_initialize_t zero_initialize;
- static inline constexpr detail::no_initialize_t no_initialize;
- static inline constexpr detail::id_initialize_t id_initialize;
-
-}
-
-#endif
diff --git a/include/detail/matrix.hpp b/include/detail/matrix.hpp
deleted file mode 100644
index 419aa29..0000000
--- a/include/detail/matrix.hpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- This file is a part of the rexy/r0nk/atlas project
- Copyright (C) 2020 rexy712
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-
-#ifndef REXY_DETAIL_MATRIX_HPP
-#define REXY_DETAIL_MATRIX_HPP
-
-#include //size_t
-#include //integer_sequence
-
-namespace math::detail{
-
- template
- struct gen_id_tup {
- using tup = typename gen_id_tup::tup;
- };
- template
- struct gen_id_tup {
- using tup = typename gen_id_tup::tup;
- };
- template
- struct gen_id_tup {
- using tup = typename gen_id_tup::tup;
- };
- template
- struct gen_id_tup {
- using tup = std::integer_sequence;
- };
-
-
- template
- struct gen_zero_tup {
- using tup = typename gen_zero_tup::tup;
- };
- template
- struct gen_zero_tup<0,Args...> {
- using tup = std::integer_sequence;
- };
-
- template
- struct id_initialization_matrix {
- using tuple = typename gen_id_tup::tup;
- };
-
-
- template
- struct default_initialization_matrix {
- using tuple = typename gen_zero_tup::tup;
- };
- template
- struct default_initialization_matrix {
- using tuple = typename id_initialization_matrix::tuple;
- };
-
- template
- class mat_ref_obj
- {
- public:
- using size_type = size_t;
-
- protected:
- T* m_data = nullptr;
- public:
- constexpr mat_ref_obj(T* d, size_type i);
- constexpr T& operator[](size_type i);
- constexpr const T& operator[](size_type i)const;
- };
- template
- struct determinate_helper {
- static constexpr T perform(const matrix& m){
- T sum = 0;
- T op = 1;
- for(size_t i = 0;i < R;++i){
- T item = op * m[0][i];
- matrix mul(no_initialize);
- for(size_t j = 1, mj = 0;j < R;++j){
- for(size_t k = 0, mk = 0;k < R;++k){
- if(k == i)
- continue;
- mul[mj][mk] = m[j][k];
- ++mk;
- }
- ++mj;
- }
- sum += item * determinate_helper::perform(mul);
- op = -op;
- }
- return sum;
- }
- };
- template
- struct determinate_helper {
- static constexpr T perform(const matrix& m){
- return (m.get(0) * ((m.get(4) * m.get(8)) - (m.get(5) * m.get(7))) -
- m.get(1) * ((m.get(3) * m.get(8)) - (m.get(5) * m.get(6))) +
- m.get(2) * ((m.get(3) * m.get(7)) - (m.get(4) * m.get(6))));
- }
- };
- template
- struct determinate_helper {
- static constexpr T perform(const matrix& m){
- return m.get(0) * m.get(3) - m.get(1) * m.get(2);
- }
- };
-
- template
- struct inverse_helper {
- //TODO generalized inverse
- };
- template
- struct inverse_helper {
- static constexpr matrix perform(const matrix& m){
- T det = m.determinate();
- if(!det)
- return matrix(zero_initialize);
- return matrix(m.get(3) / det, -(m.get(1)) / det, -(m.get(2)) / det, m.get(0) / det);
- }
- };
- template
- struct inverse_helper {
- static constexpr matrix perform(const matrix& m){
- T det = m.determinate();
- if(!det)
- return matrix(zero_initialize);
- return matrix(((m.get(4) * m.get(8)) - (m.get(5) * m.get(7))) / det,
- -((m.get(1) * m.get(8)) - (m.get(2) * m.get(7))) / det,
- ((m.get(1) * m.get(5)) - (m.get(2) * m.get(4))) / det,
- -((m.get(3) * m.get(8)) - (m.get(5) * m.get(6))) / det,
- ((m.get(0) * m.get(8)) - (m.get(2) * m.get(6))) / det,
- -((m.get(0) * m.get(5)) - (m.get(2) * m.get(3))) / det,
- ((m.get(3) * m.get(7)) - (m.get(4) * m.get(6))) / det,
- -((m.get(0) * m.get(7)) - (m.get(1) * m.get(6))) / det,
- ((m.get(0) * m.get(4)) - (m.get(1) * m.get(3))) / det);
- }
- };
- template
- struct inverse_helper {
- static constexpr matrix perform(const matrix& m){
- T det = m.determinate();
- if(!det)
- return matrix(zero_initialize);
- //Math is power
- return matrix((m.get(5) * ((m.get(10) * m.get(15)) - (m.get(11) * m.get(14))) -
- m.get(6) * ((m.get(9) * m.get(15)) - (m.get(11) * m.get(13))) +
- m.get(7) * ((m.get(9) * m.get(14)) - (m.get(10) * m.get(13)))) / det,
-
- -(m.get(1) * ((m.get(10) * m.get(15)) - (m.get(11) * m.get(14))) -
- m.get(2) * ((m.get(9) * m.get(15)) - (m.get(11) * m.get(13))) +
- m.get(3) * ((m.get(9) * m.get(14)) - (m.get(10) * m.get(13)))) / det,
-
- (m.get(1) * ((m.get(6) * m.get(15)) - (m.get(7) * m.get(14))) -
- m.get(2) * ((m.get(5) * m.get(15)) - (m.get(7) * m.get(13))) +
- m.get(3) * ((m.get(5) * m.get(14)) - (m.get(6) * m.get(13)))) / det,
-
- -(m.get(1) * ((m.get(6) * m.get(11)) - (m.get(7) * m.get(10))) -
- m.get(2) * ((m.get(5) * m.get(11)) - (m.get(7) * m.get(9))) +
- m.get(3) * ((m.get(5) * m.get(10)) - (m.get(6) * m.get(9)))) / det,
-
- -(m.get(4) * ((m.get(10) * m.get(15)) - (m.get(11) * m.get(14))) -
- m.get(6) * ((m.get(8) * m.get(15)) - (m.get(11) * m.get(12))) +
- m.get(7) * ((m.get(8) * m.get(14)) - (m.get(10) * m.get(12)))) / det,
-
- (m.get(0) * ((m.get(10) * m.get(15)) - (m.get(11) * m.get(14))) -
- m.get(2) * ((m.get(8) * m.get(15)) - (m.get(11) * m.get(12))) +
- m.get(3) * ((m.get(8) * m.get(14)) - (m.get(10) * m.get(12)))) / det,
-
- -(m.get(0) * ((m.get(6) * m.get(15)) - (m.get(7) * m.get(14))) -
- m.get(2) * ((m.get(4) * m.get(15)) - (m.get(7) * m.get(12))) +
- m.get(3) * ((m.get(4) * m.get(14)) - (m.get(6) * m.get(12)))) / det,
-
- (m.get(0) * ((m.get(6) * m.get(11)) - (m.get(7) * m.get(10))) -
- m.get(2) * ((m.get(4) * m.get(11)) - (m.get(7) * m.get(8))) +
- m.get(3) * ((m.get(4) * m.get(10)) - (m.get(6) * m.get(8)))) / det,
-
- (m.get(4) * ((m.get(9) * m.get(15)) - (m.get(11) * m.get(13))) -
- m.get(5) * ((m.get(8) * m.get(15)) - (m.get(11) * m.get(12))) +
- m.get(7) * ((m.get(8) * m.get(13)) - (m.get(9) * m.get(12)))) / det,
-
- -(m.get(0) * ((m.get(9) * m.get(15)) - (m.get(11) * m.get(13))) -
- m.get(1) * ((m.get(8) * m.get(15)) - (m.get(11) * m.get(12))) +
- m.get(3) * ((m.get(8) * m.get(13)) - (m.get(9) * m.get(12)))) / det,
-
- (m.get(0) * ((m.get(5) * m.get(15)) - (m.get(7) * m.get(13))) -
- m.get(1) * ((m.get(4) * m.get(15)) - (m.get(7) * m.get(12))) +
- m.get(3) * ((m.get(4) * m.get(13)) - (m.get(5) * m.get(12)))) / det,
-
- -(m.get(0) * ((m.get(5) * m.get(11)) - (m.get(7) * m.get(9))) -
- m.get(1) * ((m.get(4) * m.get(11)) - (m.get(7) * m.get(8))) +
- m.get(3) * ((m.get(4) * m.get(9)) - (m.get(5) * m.get(8)))) / det,
-
- -(m.get(4) * ((m.get(9) * m.get(14)) - (m.get(10) * m.get(13))) -
- m.get(5) * ((m.get(8) * m.get(14)) - (m.get(10) * m.get(12))) +
- m.get(6) * ((m.get(8) * m.get(13)) - (m.get(9) * m.get(12)))) / det,
-
- (m.get(0) * ((m.get(9) * m.get(14)) - (m.get(10) * m.get(13))) -
- m.get(1) * ((m.get(8) * m.get(14)) - (m.get(10) * m.get(12))) +
- m.get(2) * ((m.get(8) * m.get(13)) - (m.get(9) * m.get(12)))) / det,
-
- -(m.get(0) * ((m.get(5) * m.get(14)) - (m.get(6) * m.get(13))) -
- m.get(1) * ((m.get(4) * m.get(14)) - (m.get(6) * m.get(12))) +
- m.get(2) * ((m.get(4) * m.get(13)) - (m.get(5) * m.get(12)))) / det,
-
- (m.get(0) * ((m.get(5) * m.get(10)) - (m.get(6) * m.get(9))) -
- m.get(1) * ((m.get(4) * m.get(10)) - (m.get(6) * m.get(8))) +
- m.get(2) * ((m.get(4) * m.get(9)) - (m.get(5) * m.get(8)))) / det);
- }
- };
-
-}
-
-#include "matrix.tpp"
-
-#endif
diff --git a/include/detail/matrix.tpp b/include/detail/matrix.tpp
deleted file mode 100644
index b0adcd1..0000000
--- a/include/detail/matrix.tpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- This file is a part of the rexy/r0nk/atlas project
- Copyright (C) 2020 rexy712
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-
-#ifndef REXY_DETAIL_MATRIX_TPP
-#define REXY_DETAIL_MATRIX_TPP
-
-#include //size_t
-#include //integer_sequence
-
-namespace math::detail{
-
- template
- constexpr mat_ref_obj::mat_ref_obj(T* d, size_type i):
- m_data(d+i){}
-
- template
- constexpr T& mat_ref_obj::operator[](size_type i){
- return m_data[i*R];
- }
- template
- constexpr const T& mat_ref_obj::operator[](size_type i)const{
- return m_data[i*R];
- }
-
-}
-
-#endif
diff --git a/include/math/detail/matrix.hpp b/include/math/detail/matrix.hpp
new file mode 100644
index 0000000..06d74a4
--- /dev/null
+++ b/include/math/detail/matrix.hpp
@@ -0,0 +1,116 @@
+/**
+ This file is a part of our_dick
+ Copyright (C) 2020 rexy712
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+#ifndef REXY_DETAIL_MATRIX_HPP
+#define REXY_DETAIL_MATRIX_HPP
+
+#include //size_t
+#include //integer_sequence
+
+namespace math::detail{
+
+ template
+ struct gen_id_tup {
+ using tup = typename gen_id_tup::tup;
+ };
+ template
+ struct gen_id_tup {
+ using tup = typename gen_id_tup::tup;
+ };
+ template
+ struct gen_id_tup {
+ using tup = typename gen_id_tup::tup;
+ };
+ template
+ struct gen_id_tup {
+ using tup = std::integer_sequence;
+ };
+
+
+ template
+ struct gen_zero_tup {
+ using tup = typename gen_zero_tup::tup;
+ };
+ template
+ struct gen_zero_tup<0,Args...> {
+ using tup = std::integer_sequence;
+ };
+
+ template
+ struct id_initialization_matrix {
+ using tuple = typename gen_id_tup::tup;
+ };
+
+
+ template
+ struct default_initialization_matrix {
+ using tuple = typename gen_zero_tup::tup;
+ };
+ template
+ struct default_initialization_matrix {
+ using tuple = typename id_initialization_matrix::tuple;
+ };
+
+ template
+ class mat_ref_obj
+ {
+ public:
+ using size_type = size_t;
+
+ protected:
+ T* m_data = nullptr;
+ public:
+ constexpr mat_ref_obj(T* d, size_type i);
+ constexpr T& operator[](size_type i);
+ constexpr const T& operator[](size_type i)const;
+ };
+ template
+ struct determinate_helper {
+ static constexpr T perform(const matrix& m);
+ };
+ template
+ struct determinate_helper {
+ static constexpr T perform(const matrix& m);
+ };
+ template
+ struct determinate_helper {
+ static constexpr T perform(const matrix& m);
+ };
+
+ template
+ struct inverse_helper {
+ //TODO generalized inverse
+ };
+ template
+ struct inverse_helper {
+ static constexpr matrix perform(const matrix& m);
+ };
+ template
+ struct inverse_helper {
+ static constexpr matrix perform(const matrix& m);
+ };
+ template
+ struct inverse_helper {
+ static constexpr matrix perform(const matrix& m);
+ };
+
+}
+
+#include "matrix.tpp"
+
+#endif
diff --git a/include/math/detail/matrix.tpp b/include/math/detail/matrix.tpp
new file mode 100644
index 0000000..6a5358c
--- /dev/null
+++ b/include/math/detail/matrix.tpp
@@ -0,0 +1,166 @@
+/**
+ This file is a part of our_dick
+ Copyright (C) 2020 rexy712
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+#ifndef REXY_DETAIL_MATRIX_TPP
+#define REXY_DETAIL_MATRIX_TPP
+
+#include //size_t
+#include //integer_sequence
+
+namespace math::detail{
+
+ template
+ constexpr mat_ref_obj::mat_ref_obj(T* d, size_type i):
+ m_data(d+i){}
+
+ template
+ constexpr T& mat_ref_obj::operator[](size_type i){
+ return m_data[i*R];
+ }
+ template
+ constexpr const T& mat_ref_obj::operator[](size_type i)const{
+ return m_data[i*R];
+ }
+ template
+ constexpr T determinate_helper::perform(const matrix& m){
+ T sum = 0;
+ T op = 1;
+ for(size_t i = 0;i < R;++i){
+ T item = op * m[0][i];
+ matrix mul(no_initialize);
+ for(size_t j = 1, mj = 0;j < R;++j){
+ for(size_t k = 0, mk = 0;k < R;++k){
+ if(k == i)
+ continue;
+ mul[mj][mk] = m[j][k];
+ ++mk;
+ }
+ ++mj;
+ }
+ sum += item * determinate_helper::perform(mul);
+ op = -op;
+ }
+ return sum;
+ }
+ template
+ constexpr T determinate_helper::perform(const matrix& m){
+ return (m.get(0) * ((m.get(4) * m.get(8)) - (m.get(5) * m.get(7))) -
+ m.get(1) * ((m.get(3) * m.get(8)) - (m.get(5) * m.get(6))) +
+ m.get(2) * ((m.get(3) * m.get(7)) - (m.get(4) * m.get(6))));
+ }
+ template
+ constexpr T determinate_helper::perform(const matrix& m){
+ return m.get(0) * m.get(3) - m.get(1) * m.get(2);
+ }
+
+ template
+ constexpr matrix inverse_helper::perform(const matrix& m){
+ T det = m.determinate();
+ if(!det)
+ return matrix(zero_initialize);
+ return matrix(m.get(3) / det, -(m.get(1)) / det, -(m.get(2)) / det, m.get(0) / det);
+ }
+ template
+ constexpr matrix inverse_helper::perform(const matrix& m){
+ T det = m.determinate();
+ if(!det)
+ return matrix(zero_initialize);
+ return matrix(((m.get(4) * m.get(8)) - (m.get(5) * m.get(7))) / det,
+ -((m.get(1) * m.get(8)) - (m.get(2) * m.get(7))) / det,
+ ((m.get(1) * m.get(5)) - (m.get(2) * m.get(4))) / det,
+ -((m.get(3) * m.get(8)) - (m.get(5) * m.get(6))) / det,
+ ((m.get(0) * m.get(8)) - (m.get(2) * m.get(6))) / det,
+ -((m.get(0) * m.get(5)) - (m.get(2) * m.get(3))) / det,
+ ((m.get(3) * m.get(7)) - (m.get(4) * m.get(6))) / det,
+ -((m.get(0) * m.get(7)) - (m.get(1) * m.get(6))) / det,
+ ((m.get(0) * m.get(4)) - (m.get(1) * m.get(3))) / det);
+ }
+ template
+ constexpr matrix inverse_helper::perform(const matrix& m){
+ T det = m.determinate();
+ if(!det)
+ return matrix(zero_initialize);
+ //Math is power
+ return matrix((m.get(5) * ((m.get(10) * m.get(15)) - (m.get(11) * m.get(14))) -
+ m.get(6) * ((m.get(9) * m.get(15)) - (m.get(11) * m.get(13))) +
+ m.get(7) * ((m.get(9) * m.get(14)) - (m.get(10) * m.get(13)))) / det,
+
+ -(m.get(1) * ((m.get(10) * m.get(15)) - (m.get(11) * m.get(14))) -
+ m.get(2) * ((m.get(9) * m.get(15)) - (m.get(11) * m.get(13))) +
+ m.get(3) * ((m.get(9) * m.get(14)) - (m.get(10) * m.get(13)))) / det,
+
+ (m.get(1) * ((m.get(6) * m.get(15)) - (m.get(7) * m.get(14))) -
+ m.get(2) * ((m.get(5) * m.get(15)) - (m.get(7) * m.get(13))) +
+ m.get(3) * ((m.get(5) * m.get(14)) - (m.get(6) * m.get(13)))) / det,
+
+ -(m.get(1) * ((m.get(6) * m.get(11)) - (m.get(7) * m.get(10))) -
+ m.get(2) * ((m.get(5) * m.get(11)) - (m.get(7) * m.get(9))) +
+ m.get(3) * ((m.get(5) * m.get(10)) - (m.get(6) * m.get(9)))) / det,
+
+ -(m.get(4) * ((m.get(10) * m.get(15)) - (m.get(11) * m.get(14))) -
+ m.get(6) * ((m.get(8) * m.get(15)) - (m.get(11) * m.get(12))) +
+ m.get(7) * ((m.get(8) * m.get(14)) - (m.get(10) * m.get(12)))) / det,
+
+ (m.get(0) * ((m.get(10) * m.get(15)) - (m.get(11) * m.get(14))) -
+ m.get(2) * ((m.get(8) * m.get(15)) - (m.get(11) * m.get(12))) +
+ m.get(3) * ((m.get(8) * m.get(14)) - (m.get(10) * m.get(12)))) / det,
+
+ -(m.get(0) * ((m.get(6) * m.get(15)) - (m.get(7) * m.get(14))) -
+ m.get(2) * ((m.get(4) * m.get(15)) - (m.get(7) * m.get(12))) +
+ m.get(3) * ((m.get(4) * m.get(14)) - (m.get(6) * m.get(12)))) / det,
+
+ (m.get(0) * ((m.get(6) * m.get(11)) - (m.get(7) * m.get(10))) -
+ m.get(2) * ((m.get(4) * m.get(11)) - (m.get(7) * m.get(8))) +
+ m.get(3) * ((m.get(4) * m.get(10)) - (m.get(6) * m.get(8)))) / det,
+
+ (m.get(4) * ((m.get(9) * m.get(15)) - (m.get(11) * m.get(13))) -
+ m.get(5) * ((m.get(8) * m.get(15)) - (m.get(11) * m.get(12))) +
+ m.get(7) * ((m.get(8) * m.get(13)) - (m.get(9) * m.get(12)))) / det,
+
+ -(m.get(0) * ((m.get(9) * m.get(15)) - (m.get(11) * m.get(13))) -
+ m.get(1) * ((m.get(8) * m.get(15)) - (m.get(11) * m.get(12))) +
+ m.get(3) * ((m.get(8) * m.get(13)) - (m.get(9) * m.get(12)))) / det,
+
+ (m.get(0) * ((m.get(5) * m.get(15)) - (m.get(7) * m.get(13))) -
+ m.get(1) * ((m.get(4) * m.get(15)) - (m.get(7) * m.get(12))) +
+ m.get(3) * ((m.get(4) * m.get(13)) - (m.get(5) * m.get(12)))) / det,
+
+ -(m.get(0) * ((m.get(5) * m.get(11)) - (m.get(7) * m.get(9))) -
+ m.get(1) * ((m.get(4) * m.get(11)) - (m.get(7) * m.get(8))) +
+ m.get(3) * ((m.get(4) * m.get(9)) - (m.get(5) * m.get(8)))) / det,
+
+ -(m.get(4) * ((m.get(9) * m.get(14)) - (m.get(10) * m.get(13))) -
+ m.get(5) * ((m.get(8) * m.get(14)) - (m.get(10) * m.get(12))) +
+ m.get(6) * ((m.get(8) * m.get(13)) - (m.get(9) * m.get(12)))) / det,
+
+ (m.get(0) * ((m.get(9) * m.get(14)) - (m.get(10) * m.get(13))) -
+ m.get(1) * ((m.get(8) * m.get(14)) - (m.get(10) * m.get(12))) +
+ m.get(2) * ((m.get(8) * m.get(13)) - (m.get(9) * m.get(12)))) / det,
+
+ -(m.get(0) * ((m.get(5) * m.get(14)) - (m.get(6) * m.get(13))) -
+ m.get(1) * ((m.get(4) * m.get(14)) - (m.get(6) * m.get(12))) +
+ m.get(2) * ((m.get(4) * m.get(13)) - (m.get(5) * m.get(12)))) / det,
+
+ (m.get(0) * ((m.get(5) * m.get(10)) - (m.get(6) * m.get(9))) -
+ m.get(1) * ((m.get(4) * m.get(10)) - (m.get(6) * m.get(8))) +
+ m.get(2) * ((m.get(4) * m.get(9)) - (m.get(5) * m.get(8)))) / det);
+ }
+
+}
+
+#endif
diff --git a/include/math/fwd_declare.hpp b/include/math/fwd_declare.hpp
new file mode 100644
index 0000000..c40115e
--- /dev/null
+++ b/include/math/fwd_declare.hpp
@@ -0,0 +1,49 @@
+/**
+ This file is a part of our_dick
+ Copyright (C) 2020 rexy712
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+#ifndef REXY_MATH_FWD_DECLARE_HPP
+#define REXY_MATH_FWD_DECLARE_HPP
+
+#include //size_t
+
+namespace math{
+
+ template
+ class matrix;
+ template
+ class vector;
+ template
+ class quaternion;
+
+ template
+ using mat2 = matrix;
+ template
+ using mat3 = matrix;
+ template
+ using mat4 = matrix;
+
+ template
+ using vec2 = vector;
+ template
+ using vec3 = vector;
+ template
+ using vec4 = vector;
+
+}
+
+#endif
diff --git a/include/mat.hpp b/include/math/mat.hpp
similarity index 90%
rename from include/mat.hpp
rename to include/math/mat.hpp
index d9c03e1..ef4117f 100644
--- a/include/mat.hpp
+++ b/include/math/mat.hpp
@@ -1,19 +1,19 @@
/**
- This file is a part of the rexy/r0nk/atlas project
+ This file is a part of our_dick
Copyright (C) 2020 rexy712
This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
+ it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
*/
#ifndef REXY_MAT_HPP
@@ -22,7 +22,8 @@
#include //size_t
#include //integer_sequence
#include //decay_t, is_same, integral_constant
-#include "detail/math.hpp"
+#include "math_common.hpp"
+#include "fwd_declare.hpp"
namespace math{
@@ -228,11 +229,11 @@ namespace math{
template
constexpr auto operator*(const matrix& left, const matrix& right);
- template::value,int> = 0>
+ template>,int> = 0>
constexpr auto operator*(const matrix& left, U&& right);
- template::value,int> = 0>
+ template>,int> = 0>
constexpr auto operator*(U&& left, const matrix& right);
- template::value,int> = 0>
+ template>,int> = 0>
constexpr auto operator/(const matrix& left, U&& right);
template
constexpr auto operator+(const matrix& left, const matrix& right);
@@ -243,15 +244,23 @@ namespace math{
template
constexpr decltype(auto) operator*=(matrix& left, const matrix& right);
- template::value,int> = 0>
+ template>,int> = 0>
constexpr decltype(auto) operator*=(matrix& left, U&& right);
- template::value,int> = 0>
+ template>,int> = 0>
constexpr decltype(auto) operator/=(matrix& left, U&& right);
template
constexpr decltype(auto) operator+=(matrix& left, const matrix& right);
template
constexpr decltype(auto) operator-=(matrix& left, const matrix& right);
+
+ template
+ using mat2 = matrix;
+ template
+ using mat3 = matrix;
+ template
+ using mat4 = matrix;
+
}
#include "mat.tpp"
diff --git a/include/mat.tpp b/include/math/mat.tpp
similarity index 96%
rename from include/mat.tpp
rename to include/math/mat.tpp
index 733e409..60a74e5 100644
--- a/include/mat.tpp
+++ b/include/math/mat.tpp
@@ -1,19 +1,19 @@
/**
- This file is a part of the rexy/r0nk/atlas project
+ This file is a part of our_dick
Copyright (C) 2020 rexy712
This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
+ it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
*/
#ifndef REXY_MAT_TPP
@@ -23,6 +23,7 @@
#include //sin, cos
#include //decay_t, declval
#include "detail/matrix.hpp"
+#include "quat.hpp"
namespace math{
@@ -202,8 +203,8 @@ namespace math{
}
template
matrix rotation2d(T x, T y, T z){
- //TODO
- return {};
+ quaternion q(x, y, z);
+ return q.to_mat3();
}
template
@@ -242,8 +243,8 @@ namespace math{
}
template
constexpr matrix rotation3d(T angle_x, T angle_y, T angle_z){
- //TODO
- return {};
+ quaternion q(angle_x, angle_y, angle_z);
+ return q.to_mat4();
}
template
constexpr matrix translation3d(T x, T y, T z){
diff --git a/include/math/math.hpp b/include/math/math.hpp
new file mode 100644
index 0000000..2277b3e
--- /dev/null
+++ b/include/math/math.hpp
@@ -0,0 +1,27 @@
+/**
+ This file is a part of our_dick
+ Copyright (C) 2020 rexy712
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+#ifndef REXY_MATH_HPP
+#define REXY_MATH_HPP
+
+#include "math_common.hpp"
+#include "vec.hpp"
+#include "mat.hpp"
+#include "quat.hpp"
+
+#endif
diff --git a/include/math/math_common.hpp b/include/math/math_common.hpp
new file mode 100644
index 0000000..2d6bd6e
--- /dev/null
+++ b/include/math/math_common.hpp
@@ -0,0 +1,58 @@
+/**
+ This file is a part of our_dick
+ Copyright (C) 2020 rexy712
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+#ifndef REXY_DETAIL_MATH_HPP
+#define REXY_DETAIL_MATH_HPP
+
+namespace math{
+
+ namespace detail{
+ struct zero_initialize_t{};
+ struct no_initialize_t{};
+ struct id_initialize_t{};
+ struct manual_initialize_t{};
+ }
+
+ static inline constexpr detail::zero_initialize_t zero_initialize;
+ static inline constexpr detail::no_initialize_t no_initialize;
+ static inline constexpr detail::id_initialize_t id_initialize;
+ static inline constexpr detail::manual_initialize_t manual_initialize;
+
+ template
+ static constexpr T pi(){
+ return static_cast(3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821);
+ }
+ template
+ static constexpr T to_degrees(T t){
+ return (t * 180.0) / pi();
+ }
+ template
+ static constexpr T to_radians(T t){
+ return (t * pi()) / 180.0;
+ }
+
+ constexpr long double operator"" _rad(long double f){
+ return f;
+ }
+ constexpr long double operator"" _deg(long double f){
+ return to_radians(f);
+ }
+
+}
+
+#endif
diff --git a/include/math/quat.hpp b/include/math/quat.hpp
new file mode 100644
index 0000000..28e9259
--- /dev/null
+++ b/include/math/quat.hpp
@@ -0,0 +1,160 @@
+/**
+ This file is a part of our_dick
+ Copyright (C) 2020 rexy712
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+#ifndef REXY_QUAT_HPP
+#define REXY_QUAT_HPP
+
+#include //size_t
+#include //pair
+#include //is_same, is_arithmetic, integral_constant
+
+#include "math_common.hpp"
+#include "fwd_declare.hpp"
+
+namespace math{
+
+ template
+ class quaternion
+ {
+ public:
+ using value_type = T;
+ using size_type = size_t;
+ using pointer = value_type*;
+ using const_pointer = const value_type*;
+ using reference = value_type&;
+ using const_reference = const value_type&;
+
+ private:
+ value_type m_data[4];
+
+ public:
+ constexpr quaternion();
+ //Construct from Euler angles
+ constexpr quaternion(detail::zero_initialize_t);
+ constexpr quaternion(detail::id_initialize_t);
+ constexpr quaternion(detail::no_initialize_t);
+ constexpr quaternion(detail::manual_initialize_t,
+ value_type w, value_type x,
+ value_type y, value_type z);
+ quaternion(value_type bank, value_type heading, value_type attitude);
+ quaternion(const vec3& angles);
+ //Construct from axis-angle
+ quaternion(value_type angle, const vec3& axis);
+ quaternion(value_type angle, value_type x, value_type y, value_type z);
+ //Copy ctor
+ constexpr quaternion(const quaternion&) = default;
+ constexpr quaternion(quaternion&&) = default;
+ ~quaternion() = default;
+
+ //Assignment
+ constexpr quaternion& operator=(const quaternion&) = default;
+ constexpr quaternion& operator=(quaternion&&) = default;
+
+ //Direct array access
+ constexpr operator pointer();
+ constexpr operator const_pointer()const;
+ constexpr reference operator[](size_type i);
+ constexpr const_reference operator[](size_type i)const;
+ constexpr reference get(size_type i);
+ constexpr const_reference get(size_type i)const;
+
+ constexpr reference w();
+ constexpr const_reference w()const;
+ constexpr reference x();
+ constexpr const_reference x()const;
+ constexpr reference y();
+ constexpr const_reference y()const;
+ constexpr reference z();
+ constexpr const_reference z()const;
+
+ //Assign axis from angle-axis
+ void set_axis(value_type x, value_type y, value_type z);
+ void set_axis(const vec3& axis);
+ vec3 get_axis()const;
+
+ void set_angle(value_type a);
+ value_type get_angle()const;
+ value_type norm()const;
+ quaternion conjugate()const;
+ quaternion inverse()const;
+ value_type magnitude()const;
+ quaternion normalize()const;
+
+ vec3 get_right()const;
+ vec3 get_up()const;
+ vec3 get_forward()const;
+
+ //Explicit Conversion1
+ vec3 to_vec3()const;
+ vec4 to_vec4()const;
+ mat3 to_mat3()const;
+ mat4 to_mat4()const;
+ vec3 to_euler_angles()const;
+ std::pair> to_axis_angle()const;
+ };
+
+ namespace detail{
+
+ template
+ struct is_quat_helper {
+ template
+ static std::true_type test(quaternion*);
+ static std::false_type test(void*);
+ static constexpr bool value = std::is_same*>(nullptr)))>::value;
+ };
+ }
+ template
+ struct is_quaternion {
+ static constexpr bool value = (detail::is_quat_helper::value && ...);
+ };
+
+ template
+ bool operator==(const quaternion& left, const quaternion& right);
+ template
+ bool operator!=(const quaternion& left, const quaternion& right);
+ template
+ auto operator-(const quaternion& left);
+ template
+ auto operator-(const quaternion& left, const quaternion& right);
+ template
+ auto operator+(const quaternion& left, const quaternion& right);
+ template