src/matrix.h

Sun, 26 Jan 2020 01:06:27 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 26 Jan 2020 01:06:27 +0200
changeset 32
767592024ec5
parent 26
3a9e761e4faa
permissions
-rw-r--r--

fix default angle

24
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
1 /*
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
2 * LDForge: LDraw parts authoring CAD
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
3 * Copyright (C) 2013 - 2020 Teemu Piippo
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
4 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
5 * This program is free software: you can redistribute it and/or modify
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
6 * it under the terms of the GNU General Public License as published by
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
8 * (at your option) any later version.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
9 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
10 * This program is distributed in the hope that it will be useful,
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
13 * GNU General Public License for more details.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
14 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
15 * You should have received a copy of the GNU General Public License
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
17 */
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
18
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #pragma once
11
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
20 #include <QGenericMatrix>
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
21 #include <type_traits>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
22
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
23 template<int Rows, int Columns, typename T = double>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
24 struct MatrixIterator;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
25
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
26 template<int Rows, int Columns>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
27 struct MatrixIndex
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
28 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
29 int row;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
30 int column;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
31 };
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 template<int Rows, int Columns, typename T = double>
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34 struct Matrix
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
35 {
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
36 using Iterator = MatrixIterator<Rows, Columns, T>;
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
37 T values[Rows][Columns];
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
38 Iterator begin()
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
39 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
40 return {*this, {0, 0}};
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
41 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
42 Iterator end()
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
43 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
44 return {*this, {Rows, 0}};
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
45 }
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46 T& operator()(int row, int column)
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
47 {
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
48 return this->values[row][column];
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
49 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
50 T operator()(int row, int column) const
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
51 {
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
52 return this->values[row][column];
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
53 }
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
54 T& operator[](const MatrixIndex<Rows, Columns>& index)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
55 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
56 return (*this)(index.row, index.column);
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
57 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
58 T operator[](const MatrixIndex<Rows, Columns>& index) const
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
59 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
60 return (*this)(index.row, index.column);
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
61 }
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
62 };
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
63
11
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
64 template<int Rows, int Columns, typename T>
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
65 struct MatrixIterator
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
66 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
67 struct Value
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
68 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
69 const MatrixIndex<Rows, Columns> index;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
70 decltype(std::declval<Matrix<Rows, Columns, T>>()(0, 0)) value;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
71 };
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
72 Matrix<Rows, Columns, T>& matrix;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
73 MatrixIndex<Rows, Columns> index;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
74 };
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
75
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
76 template<int Rows, int Columns>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
77 auto& operator++(MatrixIndex<Rows, Columns>& index)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
78 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
79 index.column += 1;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
80 if (index.column >= Columns)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
81 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
82 index.row += 1;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
83 index.column -= Columns;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
84 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
85 return index;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
86 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
87
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
88 template<int Rows, int Columns>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
89 bool operator==(
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
90 const MatrixIndex<Rows, Columns>& one,
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
91 const MatrixIndex<Rows, Columns>& other)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
92 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
93 return one.row == other.row and one.column == other.column;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
94 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
95 template<int Rows, int Columns, typename T>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
96 auto& operator++(MatrixIterator<Rows, Columns, T>& iterator)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
97 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
98 ++iterator.index;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
99 return iterator;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
100 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
101
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
102 template<int Rows, int Columns, typename T>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
103 bool operator==(
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
104 const MatrixIterator<Rows, Columns, T>& one,
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
105 const MatrixIterator<Rows, Columns, T>& other)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
106 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
107 return &one.matrix == &other.matrix and one.index == other.index;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
108 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
109
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
110 template<int Rows, int Columns, typename T>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
111 bool operator!=(
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
112 const MatrixIterator<Rows, Columns, T>& one,
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
113 const MatrixIterator<Rows, Columns, T>& other)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
114 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
115 return not (one == other);
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
116 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
117
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
118 template<int Rows, int Columns, typename T>
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
119 auto operator*(MatrixIterator<Rows, Columns, T>& iterator)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
120 -> typename MatrixIterator<Rows, Columns, T>::Value
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
121 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
122 return {iterator.index, iterator.matrix[iterator.index]};
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
123 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
124
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
125 template<int Rows, int Columns, typename T>
11
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
126 QGenericMatrix<Rows, Columns, T> matrixToQGenericMatrix(const Matrix<Rows, Columns, T>& matrix)
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
127 {
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
128 return {matrix.values};
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
129 }
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
130
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
131 template<int Rows, int Columns, typename T>
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
132 Matrix<Rows, Columns, T> matrixFromQGenericMatrix(const QGenericMatrix<Rows, Columns, T&> matrix)
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
133 {
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
134 Matrix<Rows, Columns, T> result;
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
135 for (auto& cell : result)
11
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
136 {
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
137 matrix(cell.index.row, cell.index.column) = result[cell.index];
11
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
138 }
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
139 return result;
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
140 }
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
141
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
142 using Matrix3x3 = Matrix<3, 3>;
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
143 Q_DECLARE_METATYPE(Matrix3x3);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
144 using Matrix4x4 = Matrix<4, 4>;
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
145 Q_DECLARE_METATYPE(Matrix4x4);
11
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
146
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
147 template<int Rows, int Columns, typename T>
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
148 QDataStream& operator<<(QDataStream& stream, const Matrix<Rows, Columns, T>& matrix)
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
149 {
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
150 for (auto& cell : matrix)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
151 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
152 stream << cell.value;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
153 }
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
154 return stream;
11
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
155 }
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
156
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
157 template<int Rows, int Columns, typename T>
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
158 QDataStream& operator>>(QDataStream& stream, Matrix<Rows, Columns, T>& matrix)
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
159 {
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
160 for (auto& cell : matrix)
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
161 {
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
162 stream >> cell.value;
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
163 }
11
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
164 return stream;
771168ee2c76 added matrix conversions and datastream operators
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
165 }
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
166
21
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
167 Matrix4x4 combine(const Matrix3x3& topLeft, const struct Point3D& translation);
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
168
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
169 static constexpr Matrix3x3 identity3x3 {{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}};
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 11
diff changeset
170 static constexpr Matrix4x4 identity4x4 {{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}};
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
171
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
172 namespace math
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
173 {
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
174 qreal det(qreal a, qreal b, qreal c, qreal d, qreal e, qreal f, qreal g, qreal h, qreal i);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
175 qreal det(const Matrix<2, 2>& matrix);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
176 qreal det(const Matrix3x3& matrix);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
177 qreal det(const Matrix4x4& matrix);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
178 }

mercurial