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
#ifndef MATRIX2_HPP
21
#define MATRIX2_HPP
22
23
#include <iostream>
24
#include <vector>
25
26
#include <
exception_cpe.hpp
>
27
28
namespace
cpe
29
{
30
class
vec2;
31
32
34
class
matrix2
35
{
36
37
public
:
38
39
// ********************************************* //
40
// ********************************************* //
41
// CONSTRUCTORS
42
// ********************************************* //
43
// ********************************************* //
44
46
matrix2
();
48
matrix2
(
float
x00,
float
x01,
49
float
x10,
float
x11);
50
51
// ********************************************* //
52
// ********************************************* //
53
// Special initialization
54
// ********************************************* //
55
// ********************************************* //
56
58
static
matrix2
identity
();
60
static
matrix2
zeros
();
62
static
matrix2
rotation
(
float
angle);
64
static
matrix2
scale
(
float
s);
66
static
matrix2
scale
(
float
s_x,
float
s_y);
67
68
69
// ********************************************* //
70
// ********************************************* //
71
// Element access
72
// ********************************************* //
73
// ********************************************* //
74
76
float
operator()
(
const
size_t
& k1,
const
size_t
& k2)
const
;
78
float
&
operator()
(
const
size_t
& k1,
const
size_t
& k2);
79
82
const
float
*
pointer
()
const
;
85
float
*
pointer_unprotected
();
86
87
88
89
// ********************************************* //
90
// ********************************************* //
91
// Math operator
92
// ********************************************* //
93
// ********************************************* //
94
96
matrix2
operator+
(
const
matrix2
& m2)
const
;
98
matrix2
operator+
(
float
s)
const
;
99
101
matrix2
operator-
(
const
matrix2
& m2)
const
;
103
matrix2
operator-
(
float
s)
const
;
104
105
107
matrix2
operator*
(
float
s)
const
;
109
vec2
operator*
(
const
vec2
& v)
const
;
111
matrix2
operator*
(
const
matrix2
& m2)
const
;
113
matrix2
operator/
(
float
s)
const
;
114
115
117
matrix2
&
operator+=
(
const
matrix2
&
m
);
119
matrix2
&
operator+=
(
float
s);
121
matrix2
&
operator-=
(
const
matrix2
& m);
123
matrix2
&
operator-=
(
float
s);
125
matrix2
&
operator*=
(
float
s);
127
matrix2
&
operator/=
(
float
s);
128
130
matrix2
operator-
()
const
;
131
133
matrix2
product_compontentwise
(
const
matrix2
& m)
const
;
135
matrix2
&
product_compontentwise_internal
(
const
matrix2
& m);
136
138
matrix2
transposed
()
const
;
139
140
141
142
143
144
145
146
// ********************************************* //
147
// ********************************************* //
148
// Projection matrix
149
// ********************************************* //
150
// ********************************************* //
151
153
std::vector<float>
to_vector
()
const
;
154
155
private
:
156
157
// ********************************************* //
158
// ********************************************* //
159
// Internal parameters
160
// ********************************************* //
161
// ********************************************* //
162
164
float
m[4];
165
166
167
// ********************************************* //
168
// ********************************************* //
169
// Helper
170
// ********************************************* //
171
// ********************************************* //
172
174
void
assert_size
(
const
size_t
& k1,
const
size_t
& k2)
const
;
175
176
};
177
179
matrix2
operator+
(
float
s,
const
matrix2
& m);
181
matrix2
operator-
(
float
s,
const
matrix2
& m);
183
matrix2
operator*
(
float
s,
const
matrix2
& m);
184
185
// ********************************************* //
186
// ********************************************* //
187
// Output
188
// ********************************************* //
189
// ********************************************* //
190
192
std::ostream&
operator<<
(std::ostream& stream,
const
matrix2
& m);
193
194
195
197
class
exception_matrix2
:
public
exception_cpe
198
{
199
public
:
200
202
exception_matrix2
():
exception_cpe
(){}
204
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){}
205
};
206
207
208
209
}
210
211
#endif
lib3d
matrix2.hpp
Generated on Sun Apr 28 2013 11:11:29 by
1.8.3.1