Main Page
Namespaces
Classes
Files
File List
File Members
matrix3.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 MATRIX3_HPP
22
#define MATRIX3_HPP
23
24
#include <iostream>
25
#include <vector>
26
27
#include <
exception_cpe.hpp
>
28
29
namespace
cpe
30
{
31
class
vec3;
32
33
35
class
matrix3
36
{
37
38
public
:
39
40
// ********************************************* //
41
// ********************************************* //
42
// CONSTRUCTORS
43
// ********************************************* //
44
// ********************************************* //
45
47
matrix3
();
49
matrix3
(
float
x00,
float
x01,
float
x02,
50
float
x10,
float
x11,
float
x12,
51
float
x20,
float
x21,
float
x22);
52
53
// ********************************************* //
54
// ********************************************* //
55
// Special initialization
56
// ********************************************* //
57
// ********************************************* //
58
60
static
matrix3
identity
();
62
static
matrix3
zeros
();
64
static
matrix3
rotation
(
const
vec3
& axis,
float
angle);
66
static
matrix3
scale
(
float
s);
68
static
matrix3
scale
(
float
s_x,
float
s_y,
float
s_z);
69
70
71
// ********************************************* //
72
// ********************************************* //
73
// Element access
74
// ********************************************* //
75
// ********************************************* //
76
78
float
operator()
(
const
size_t
& k1,
const
size_t
& k2)
const
;
80
float
&
operator()
(
const
size_t
& k1,
const
size_t
& k2);
81
84
const
float
*
pointer
()
const
;
87
float
*
pointer_unprotected
();
88
89
90
91
// ********************************************* //
92
// ********************************************* //
93
// Math operator
94
// ********************************************* //
95
// ********************************************* //
96
98
matrix3
operator+
(
const
matrix3
& m2)
const
;
100
matrix3
operator+
(
float
s)
const
;
101
103
matrix3
operator-
(
const
matrix3
& m2)
const
;
105
matrix3
operator-
(
float
s)
const
;
106
107
109
matrix3
operator*
(
float
s)
const
;
111
vec3
operator*
(
const
vec3
& v)
const
;
113
matrix3
operator*
(
const
matrix3
& m2)
const
;
115
matrix3
operator/
(
float
s)
const
;
116
117
119
matrix3
&
operator+=
(
const
matrix3
&
m
);
121
matrix3
&
operator+=
(
float
s);
123
matrix3
&
operator-=
(
const
matrix3
& m);
125
matrix3
&
operator-=
(
float
s);
127
matrix3
&
operator*=
(
float
s);
129
matrix3
&
operator/=
(
float
s);
130
132
matrix3
operator-
()
const
;
133
135
matrix3
product_compontentwise
(
const
matrix3
& m)
const
;
137
matrix3
&
product_compontentwise_internal
(
const
matrix3
& m);
138
140
matrix3
transposed
()
const
;
141
142
143
144
// ********************************************* //
145
// ********************************************* //
146
// Projection matrix
147
// ********************************************* //
148
// ********************************************* //
149
151
std::vector<float>
to_vector
()
const
;
152
153
private
:
154
155
// ********************************************* //
156
// ********************************************* //
157
// Internal parameters
158
// ********************************************* //
159
// ********************************************* //
160
162
float
m[9];
163
164
165
// ********************************************* //
166
// ********************************************* //
167
// Helper
168
// ********************************************* //
169
// ********************************************* //
170
172
void
assert_size
(
const
size_t
& k1,
const
size_t
& k2)
const
;
173
174
};
175
177
matrix3
operator+
(
float
s,
const
matrix3
& m);
179
matrix3
operator-
(
float
s,
const
matrix3
& m);
181
matrix3
operator*
(
float
s,
const
matrix3
& m);
182
183
// ********************************************* //
184
// ********************************************* //
185
// Output
186
// ********************************************* //
187
// ********************************************* //
188
190
std::ostream&
operator<<
(std::ostream& stream,
const
matrix3
& m);
191
193
class
exception_matrix3
:
public
exception_cpe
194
{
195
public
:
196
198
exception_matrix3
():
exception_cpe
(){}
200
exception_matrix3
(
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){}
201
};
202
203
204
205
}
206
207
#endif
lib3d
matrix3.hpp
Generated on Fri Mar 29 2013 22:45:31 by
1.8.3.1