matrix1x4.hpp
Go to the documentation of this file.
1 /*
2 ** TP CPE Lyon
3 ** Copyright (C) 2014 Damien Rohmer
4 **
5 ** This program is free software: you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation, either version 3 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 
21 #ifndef MATRIX1X4_HPP
22 #define MATRIX1X4_HPP
23 
24 #include <iostream>
25 #include <vector>
26 
27 #include "../libcommon/exception_cpe.hpp"
28 
29 namespace cpe
30 {
31 
32 class matrix4x1;
33 class matrix4;
34 
36 class matrix1x4
37 {
38 
39 public:
40 
41  // ********************************************* //
42  // ********************************************* //
43  // CONSTRUCTORS
44  // ********************************************* //
45  // ********************************************* //
46 
48  matrix1x4();
50  matrix1x4(float x00,float x01,float x02,float x03);
51 
52 
53 
54  // ********************************************* //
55  // ********************************************* //
56  // Element access
57  // ********************************************* //
58  // ********************************************* //
59 
61  float operator()(const size_t& k1,const size_t& k2) const;
63  float& operator()(const size_t& k1,const size_t& k2);
64 
67  const float* pointer() const;
70  float* pointer_unprotected();
71 
72 
73 
74  // ********************************************* //
75  // ********************************************* //
76  // Math operator
77  // ********************************************* //
78  // ********************************************* //
79 
81  matrix1x4 operator+(const matrix1x4& m2) const;
83  matrix1x4 operator+(float s) const;
84 
86  matrix1x4 operator-(const matrix1x4& m2) const;
88  matrix1x4 operator-(float s) const;
89 
90 
92  matrix1x4 operator*(float s) const;
94  matrix1x4 operator*(const matrix4 s) const;
96  float operator*(const matrix4x1& m2) const;
98  matrix1x4 operator/(float s) const;
99 
100 
102  matrix1x4& operator+=(const matrix1x4& m);
104  matrix1x4& operator+=(float s);
106  matrix1x4& operator-=(const matrix1x4& m);
108  matrix1x4& operator-=(float s);
110  matrix1x4& operator*=(float s);
112  matrix1x4& operator/=(float s);
113 
115  matrix1x4 operator-() const;
116 
121 
123  matrix4x1 transposed() const;
124 
125 
126 
127 
128 
129 
130 
131  // ********************************************* //
132  // ********************************************* //
133  // Projection matrix
134  // ********************************************* //
135  // ********************************************* //
136 
138  std::vector<float> to_vector() const;
139 
140 private:
141 
142  // ********************************************* //
143  // ********************************************* //
144  // Internal parameters
145  // ********************************************* //
146  // ********************************************* //
147 
149  float m[4];
150 
151 
152  // ********************************************* //
153  // ********************************************* //
154  // Helper
155  // ********************************************* //
156  // ********************************************* //
157 
159  void assert_size(const size_t& k1,const size_t& k2) const;
160 
161 };
162 
164 matrix1x4 operator+(float s,const matrix1x4& m);
166 matrix1x4 operator-(float s,const matrix1x4& m);
168 matrix1x4 operator*(float s,const matrix1x4& m);
169 
170 // ********************************************* //
171 // ********************************************* //
172 // Output
173 // ********************************************* //
174 // ********************************************* //
175 
177 std::ostream& operator<<(std::ostream& stream,const matrix1x4& m);
178 
179 
180 
181 
182 
183 
184 
185 }
186 
187 #endif
matrix1x4()
empty constructor (identity)
Definition: matrix1x4.cpp:33
matrix4x1 transposed() const
transpose matrix
Definition: matrix1x4.cpp:215
void assert_size(const size_t &k1, const size_t &k2) const
assert that a size_t belongs to 0x[[0,3]]
Definition: matrix1x4.cpp:189
Matrix 1x4.
Definition: matrix1x4.hpp:36
matrix1x4 operator-() const
unary negation
Definition: matrix1x4.cpp:164
std::vector< float > to_vector() const
convert 1x4 matrix into a vector of float of size 4
Definition: matrix1x4.cpp:207
matrix1x4 & operator/=(float s)
internal /
Definition: matrix1x4.cpp:157
matrix1x4 operator-(float s, const matrix1x4 &m)
operator
Definition: matrix1x4.cpp:82
Matrix 1x4.
Definition: matrix4x1.hpp:36
matrix1x4 operator+(float s, const matrix1x4 &m)
operator
Definition: matrix1x4.cpp:61
matrix1x4 & operator*=(float s)
internal *
Definition: matrix1x4.cpp:150
matrix1x4 & operator-=(const matrix1x4 &m)
internal -
Definition: matrix1x4.cpp:135
Matrix 4x4.
Definition: matrix4.hpp:37
matrix1x4 operator*(float s, const matrix1x4 &m)
multiply by a scalar operator
Definition: matrix1x4.cpp:93
std::ostream & operator<<(std::ostream &stream, const matrix1x4 &_m)
output the vector in ostream
Definition: matrix1x4.cpp:182
matrix1x4 operator/(float s) const
divide by a scalar operator
Definition: matrix1x4.cpp:115
matrix1x4 product_compontentwise(const matrix1x4 &m) const
does componentwise multiplication
Definition: matrix1x4.cpp:168
float * pointer_unprotected()
fast pointer access
Definition: matrix1x4.cpp:203
matrix1x4 operator*(float s) const
multiply by a scalar operator
Definition: matrix1x4.cpp:100
matrix1x4 & operator+=(const matrix1x4 &m)
internal +
Definition: matrix1x4.cpp:120
const float * pointer() const
fast pointer access
Definition: matrix1x4.cpp:199
matrix1x4 operator+(const matrix1x4 &m2) const
operator
Definition: matrix1x4.cpp:54
float m[4]
internal storage of the matrix
Definition: matrix1x4.hpp:149
matrix1x4 & product_compontentwise_internal(const matrix1x4 &m)
does componentwise multiplication
Definition: matrix1x4.cpp:174
float operator()(const size_t &k1, const size_t &k2) const
Access to the k_th entry (k in [0,1])
Definition: matrix1x4.cpp:43