VPP  0.8
A high-level modern C++ API for Vulkan
vppLangMatrixTypes.hpp
1 /*
2  Copyright 2016-2018 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 // -----------------------------------------------------------------------------
28 namespace vpp {
29 // -----------------------------------------------------------------------------
30 
59 class Mat4
60 {
61 public:
66  Mat4 ( const std::initializer_list< float >& init );
67 
71  Mat4 ( const std::initializer_list< Vec4 >& init );
72 
76  Mat4 ( const std::initializer_list< Float >& init );
77 
79  Mat4 operator+ ( const Mat4& rhs ) const;
80 
82  Mat4 operator- ( const Mat4& rhs ) const;
83 
85  Mat2x4 operator* ( const Mat2x4& rhs ) const;
86 
88  Mat3x4 operator* ( const Mat3x4& rhs ) const;
89 
91  Mat4 operator* ( const Mat4& rhs ) const;
92 
94  Vec4 operator* ( const Vec4& rhs ) const;
95 
97  Mat4 operator* ( const Float& rhs ) const;
98 
100  Mat4 operator/ ( const Mat4& rhs ) const;
101 
103  Mat4 operator% ( const Mat4& rhs ) const;
104 
106  Mat4 operator-() const;
107 
109  template< typename IndexT >
110  auto operator[]( IndexT index ) const;
111 };
112 
113 // -----------------------------------------------------------------------------
121 class Mat2 {};
122 
130 class Mat3 {};
131 
139 class Mat3x2 {};
140 
148 class Mat4x2 {};
149 
157 class Mat2x3 {};
158 
166 class Mat4x3 {};
167 
175 class Mat2x4 {};
176 
184 class Mat3x4 {};
185 
186 // -----------------------------------------------------------------------------
199 class IMat4
200 {
201 public:
205  IMat4 ( const std::initializer_list< int >& init );
206 
210  IMat4 ( const std::initializer_list< IVec4 >& init );
211 
215  IMat4 ( const std::initializer_list< Int >& init );
216 
218  IMat4 operator+ ( const IMat4& rhs ) const;
219 
221  IMat4 operator- ( const IMat4& rhs ) const;
222 
224  IMat2x4 operator* ( const IMat2x4& rhs ) const;
225 
227  IMat3x4 operator* ( const IMat3x4& rhs ) const;
228 
230  IMat4 operator* ( const IMat4& rhs ) const;
231 
233  IVec4 operator* ( const IVec4& rhs ) const;
234 
236  IMat4 operator* ( const Int& rhs ) const;
237 
239  IMat4 operator/ ( const IMat4& rhs ) const;
240 
242  IMat4 operator% ( const IMat4& rhs ) const;
243 
245  IMat4 operator<< ( const IMat4& rhs ) const;
246 
248  IMat4 operator>> ( const IMat4& rhs ) const;
249 
251  IMat4 operator& ( const IMat4& rhs ) const;
252 
254  IMat4 operator| ( const IMat4& rhs ) const;
255 
257  IMat4 operator^ ( const IMat4& rhs ) const;
258 
260  IMat4 operator-() const;
261 
263  IMat4 operator~() const;
264 
266  template< typename IndexT >
267  auto operator[]( IndexT index ) const;
268 };
269 
270 // -----------------------------------------------------------------------------
271 
279 class IMat2 {};
280 
288 class IMat3 {};
289 
297 class IMat3x2 {};
298 
306 class IMat4x2 {};
307 
315 class IMat2x3 {};
316 
324 class IMat4x3 {};
325 
333 class IMat2x4 {};
334 
342 class IMat3x4 {};
343 
344 // -----------------------------------------------------------------------------
371 class VMat4
372 {
373 public:
375  VMat4();
376 
378  VMat4 ( const Mat4& rhs );
379 
381  VMat4 ( const VMat4& rhs );
382 
386  const VMat4& operator= ( const Mat4& rhs );
387 
391  operator Mat4() const;
392 
394  template< typename IndexT >
395  auto operator[]( IndexT index ) const;
396 };
397 
398 // -----------------------------------------------------------------------------
407 class VMat2 {};
408 
417 class VMat3 {};
418 
427 class VMat3x2 {};
428 
437 class VMat4x2 {};
438 
447 class VMat2x3 {};
448 
457 class VMat4x3 {};
458 
467 class VMat2x4 {};
468 
477 class VMat3x4 {};
478 
479 // -----------------------------------------------------------------------------
480 } // namespace vpp
481 // -----------------------------------------------------------------------------
Shader (GPU-side) data type for mutable variables of 2 columns, 3 rows 32-bit float matrix type...
Definition: vppLangMatrixTypes.hpp:447
Shader (GPU-side) data type for mutable variables of 4 columns, 3 rows 32-bit float matrix type...
Definition: vppLangMatrixTypes.hpp:457
VMat4()
Constructs uninitialized matrix variable.
Shader (GPU-side) data type for 3x3 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:288
IMat4 operator/(const IMat4 &rhs) const
Division operation on matrix components.
IMat4 operator%(const IMat4 &rhs) const
Remainder operation on matrix components.
IMat4 operator+(const IMat4 &rhs) const
Addition operation on matrix components.
auto operator[](IndexT index) const
Retrieves a column vector from matrix variable.
Shader (GPU-side) data type for 4 columns, 2 rows 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:306
Shader (GPU-side) data type for 3 columns, 2 rows 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:297
IMat4 operator^(const IMat4 &rhs) const
Bitwise XOR operation on matrix components.
The VPP namespace.
Definition: main.hpp:1
const VMat4 & operator=(const Mat4 &rhs)
Assigns new value to matrix variable.
Shader (GPU-side) data type for mutable variables of 3 columns, 2 rows 32-bit float matrix type...
Definition: vppLangMatrixTypes.hpp:427
Shader (GPU-side) data type for mutable variables of 4 columns, 2 rows 32-bit float matrix type...
Definition: vppLangMatrixTypes.hpp:437
IMat4 operator &(const IMat4 &rhs) const
Bitwise AND operation on matrix components.
auto operator[](IndexT index) const
Retrieves a column vector from matrix variable.
Mat4 operator-() const
Negation operation on matrix components.
IMat4 operator<<(const IMat4 &rhs) const
Shift to left operation on matrix components.
IMat4 operator|(const IMat4 &rhs) const
Bitwise OR operation on matrix components.
Shader (GPU-side) data type for 4 columns, 3 rows 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:166
Shader (GPU-side) data type for mutable variables of 3x3 32-bit float matrix type.
Definition: vppLangMatrixTypes.hpp:417
Shader (GPU-side) data type for 2 columns, 3 rows 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:157
Mat4 operator/(const Mat4 &rhs) const
Division operation on matrix components.
Shader (GPU-side) data type for mutable variables of 2x2 32-bit float matrix type.
Definition: vppLangMatrixTypes.hpp:407
Mat4 operator%(const Mat4 &rhs) const
Remainder operation on matrix components.
IMat4 operator-() const
Arithmetic negation operation on matrix components.
Shader (GPU-side) data type for 4 columns, 2 rows 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:148
Shader (GPU-side) data type for 3 columns, 2 rows 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:139
Shader (GPU-side) data type for mutable variables of 4x4 32-bit floating point matrix type...
Definition: vppLangMatrixTypes.hpp:371
Shader (GPU-side) data type for 3 columns, 4 rows 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:184
Shader (GPU-side) data type for 2 columns, 4 rows 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:175
Shader (GPU-side) data type for 2x2 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:121
Shader (GPU-side) data type for 4-element 32-bit integer vectors.
Definition: vppLangVectorTypes.hpp:640
Shader (GPU-side) data type for 4x4 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:59
Shader (GPU-side) data type for 32-bit floating point values.
Definition: vppLangScalarTypes.hpp:356
Shader (GPU-side) data type for 4-element 32-bit float vectors.
Definition: vppLangVectorTypes.hpp:314
IMat4 operator~() const
Bitwise negation operation on matrix components.
Shader (GPU-side) data type for 3 columns, 4 rows 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:342
Shader (GPU-side) data type for 2 columns, 4 rows 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:333
Mat4 operator+(const Mat4 &rhs) const
Addition operation on matrix components.
Shader (GPU-side) data type for 32-bit signed integer values.
Definition: vppLangScalarTypes.hpp:162
Shader (GPU-side) data type for mutable variables of 2 columns, 4 rows 32-bit float matrix type...
Definition: vppLangMatrixTypes.hpp:467
Shader (GPU-side) data type for mutable variables of 3 columns, 4 rows 32-bit float matrix type...
Definition: vppLangMatrixTypes.hpp:477
Mat4(const std::initializer_list< float > &init)
Matrix initialization (by constants) with curly braces syntax.
Shader (GPU-side) data type for 3x3 32-bit float matrices.
Definition: vppLangMatrixTypes.hpp:130
IMat4 operator>>(const IMat4 &rhs) const
Shift to right operation on matrix components.
auto operator[](IndexT index) const
Retrieves a column vector from matrix variable.
Shader (GPU-side) data type for 2x2 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:279
IMat2x4 operator*(const IMat2x4 &rhs) const
Matrix multiplication by 2-column matrix.
Shader (GPU-side) data type for 4x4 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:199
Mat2x4 operator*(const Mat2x4 &rhs) const
Matrix multiplication by 2-column matrix.
Shader (GPU-side) data type for 4 columns, 3 rows 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:324
IMat4(const std::initializer_list< int > &init)
Matrix initialization (by constants) with curly braces syntax.
Shader (GPU-side) data type for 2 columns, 3 rows 32-bit integer matrices.
Definition: vppLangMatrixTypes.hpp:315