-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectionMatrix.cpp
More file actions
41 lines (35 loc) · 988 Bytes
/
ProjectionMatrix.cpp
File metadata and controls
41 lines (35 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "ProjectionMatrix.hpp"
ProjectionMatrix::ProjectionMatrix( void )
{
std::cout << "[ProjectionMatrix] created" << std::endl;
return ;
}
ProjectionMatrix::ProjectionMatrix( double const angle, double const ratio, double const near, double const far )
{
double scale = 1 / std::tan((angle / 2) / 180.0 * M_PI);
double tab[4][4] = {
{ scale / ratio, 0, 0, 0 },
{ 0, scale, 0, 0 },
{ 0, 0, (far + near) / (near - far), (2 * far * near) / (near - far) },
{ 0, 0, -1, 0 },
};
std::cout << "[ProjectionMatrix] created" << std::endl;
this->_initialize(tab);
return ;
}
ProjectionMatrix::ProjectionMatrix(ProjectionMatrix const & src)
{
std::cout << "[ProjectionMatrix] created" << std::endl;
*this = src;
return ;
}
ProjectionMatrix::~ProjectionMatrix( void )
{
std::cout << "[ProjectionMatrix] destructed" << std::endl;
return ;
}
ProjectionMatrix & ProjectionMatrix::operator=(ProjectionMatrix const & rhs)
{
this->_initialize(rhs._values);
return *this;
}