Main Page
Namespaces
Classes
Files
File List
File Members
matrix2.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 MATRIX2_HPP
22
#define MATRIX2_HPP
23
24
#include <iostream>
25
#include <vector>
26
27
#include <
exception_cpe.hpp
>
28
29
namespace
cpe
30
{
31
class
vec2;
32
33
35
class
matrix2
36
{
37
38
public
:
39
40
// ********************************************* //
41
// ********************************************* //
42
// CONSTRUCTORS
43
// ********************************************* //
44
// ********************************************* //
45
47
matrix2
();
49
matrix2
(
float
x00,
float
x01,
50
float
x10,
float
x11);
51
52
// ********************************************* //
53
// ********************************************* //
54
// Special initialization
55
// ********************************************* //
56
// ********************************************* //
57
59
static
matrix2
identity
();
61
static
matrix2
zeros
();
63
static
matrix2
rotation
(
float
angle);
65
static
matrix2
scale
(
float
s);
67
static
matrix2
scale
(
float
s_x,
float
s_y);
68
69
70
// ********************************************* //
71
// ********************************************* //
72
// Element access
73
// ********************************************* //
74
// ********************************************* //
75
77
float
operator()
(
const
size_t
& k1,
const
size_t
& k2)
const
;
79
float
&
operator()
(
const
size_t
& k1,
const
size_t
& k2);
80
83
const
float
*
pointer
()
const
;
86
float
*
pointer_unprotected
();
87
88
89
90
// ********************************************* //
91
// ********************************************* //
92
// Math operator
93
// ********************************************* //
94
// ********************************************* //
95
97
matrix2
operator+
(
const
matrix2
& m2)
const
;
99
matrix2
operator+
(
float
s)
const
;
100
102
matrix2
operator-
(
const
matrix2
& m2)
const
;
104
matrix2
operator-
(
float
s)
const
;
105
106
108
matrix2
operator*
(
float
s)
const
;
110
vec2
operator*
(
const
vec2
& v)
const
;
112
matrix2
operator*
(
const
matrix2
& m2)
const
;
114
matrix2
operator/
(
float
s)
const
;
115
116
118
matrix2
&
operator+=
(
const
matrix2
&
m
);
120
matrix2
&
operator+=
(
float
s);
122
matrix2
&
operator-=
(
const
matrix2
& m);
124
matrix2
&
operator-=
(
float
s);
126
matrix2
&
operator*=
(
float
s);
128
matrix2
&
operator/=
(
float
s);
129
131
matrix2
operator-
()
const
;
132
134
matrix2
product_compontentwise
(
const
matrix2
& m)
const
;
136
matrix2
&
product_compontentwise_internal
(
const
matrix2
& m);
137
139
matrix2
transposed
()
const
;
140
141
142
143
144
145
146
147
// ********************************************* //
148
// ********************************************* //
149
// Projection matrix
150
// ********************************************* //
151
// ********************************************* //
152
154
std::vector<float>
to_vector
()
const
;
155
156
private
:
157
158
// ********************************************* //
159
// ********************************************* //
160
// Internal parameters
161
// ********************************************* //
162
// ********************************************* //
163
165
float
m[4];
166
167
168
// ********************************************* //
169
// ********************************************* //
170
// Helper
171
// ********************************************* //
172
// ********************************************* //
173
175
void
assert_size
(
const
size_t
& k1,
const
size_t
& k2)
const
;
176
177
};
178
180
matrix2
operator+
(
float
s,
const
matrix2
& m);
182
matrix2
operator-
(
float
s,
const
matrix2
& m);
184
matrix2
operator*
(
float
s,
const
matrix2
& m);
185
186
// ********************************************* //
187
// ********************************************* //
188
// Output
189
// ********************************************* //
190
// ********************************************* //
191
193
std::ostream&
operator<<
(std::ostream& stream,
const
matrix2
& m);
194
195
196
198
class
exception_matrix2
:
public
exception_cpe
199
{
200
public
:
201
203
exception_matrix2
():
exception_cpe
(){}
205
exception_matrix2
(
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){}
206
};
207
208
209
210
}
211
212
#endif
lib3d
matrix2.hpp
Generated on Fri Mar 29 2013 22:45:31 by
1.8.3.1