matrix4x1.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 matrix4x1_HPP
22 #define matrix4x1_HPP
23 
24 #include <iostream>
25 #include <vector>
26 
27 #include <exception_cpe.hpp>
28 
29 namespace cpe
30 {
31 
32 class matrix1x4;
33 class matrix4;
34 
36 class matrix4x1
37 {
38 
39 public:
40 
41  // ********************************************* //
42  // ********************************************* //
43  // CONSTRUCTORS
44  // ********************************************* //
45  // ********************************************* //
46 
48  matrix4x1();
50  matrix4x1(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  matrix4x1 operator+(const matrix4x1& m2) const;
83  matrix4x1 operator+(float s) const;
84 
86  matrix4x1 operator-(const matrix4x1& m2) const;
88  matrix4x1 operator-(float s) const;
89 
90 
92  matrix4x1 operator*(float s) const;
94  float operator*(const matrix1x4& m2) const;
96  matrix4x1 operator/(float s) const;
97 
98 
100  matrix4x1& operator+=(const matrix4x1& m);
102  matrix4x1& operator+=(float s);
104  matrix4x1& operator-=(const matrix4x1& m);
106  matrix4x1& operator-=(float s);
108  matrix4x1& operator*=(float s);
110  matrix4x1& operator/=(float s);
111 
113  matrix4x1 operator-() const;
114 
119 
121  matrix4x1 transposed() const;
122 
123 
124 
125 
126 
127 
128 
129  // ********************************************* //
130  // ********************************************* //
131  // Projection matrix
132  // ********************************************* //
133  // ********************************************* //
134 
136  std::vector<float> to_vector() const;
137 
138 private:
139 
140  // ********************************************* //
141  // ********************************************* //
142  // Internal parameters
143  // ********************************************* //
144  // ********************************************* //
145 
147  float m[4];
148 
149 
150  // ********************************************* //
151  // ********************************************* //
152  // Helper
153  // ********************************************* //
154  // ********************************************* //
155 
157  void assert_size(const size_t& k1,const size_t& k2) const;
158 
159 };
160 
162 matrix4x1 operator+(float s,const matrix4x1& m);
164 matrix4x1 operator-(float s,const matrix4x1& m);
166 matrix4x1 operator*(float s,const matrix4x1& m);
168 matrix4x1 operator*(const matrix4& m1,const matrix4x1& m2);
169 
170 
171 // ********************************************* //
172 // ********************************************* //
173 // Output
174 // ********************************************* //
175 // ********************************************* //
176 
178 std::ostream& operator<<(std::ostream& stream,const matrix4x1& m);
179 
180 
181 
184 {
185 public:
186 
190  exception_matrix4x1(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){}
191 };
192 
193 
194 
195 }
196 
197 #endif