matrix1x4.hpp
Go to the documentation of this file.
1 /*
2 ** TP CPE Lyon
3 ** Copyright (C) 2013 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 
20 
21 #ifndef MATRIX1X4_HPP
22 #define MATRIX1X4_HPP
23 
24 #include <iostream>
25 #include <vector>
26 
27 #include <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 
183 {
184 public:
185 
189  exception_matrix1x4(const std::string& msg_param,const std::string& file_param,const std::string& caller_param,const int& line_param):exception_cpe(msg_param,file_param,caller_param,line_param){}
190 };
191 
192 
193 
194 }
195 
196 #endif