-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMatrixnt.cpp
More file actions
121 lines (101 loc) · 2.98 KB
/
Matrixnt.cpp
File metadata and controls
121 lines (101 loc) · 2.98 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*********************************************************************************
*Copyright(C) 2013-2016 Qingan Yan (yanqinganssg (at) gmail.com or yanqingan (at) whu.edu.cn)
*Author: Qingan Yan
*Version: v15.2
*Date: Sep-10-2015
*Description: This program is used to display point clouds from .out and .ply file format,
which is the output of Bundler.
*Notice: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation.
*For more information, please view my homepage at https://yanqingan.github.io
**********************************************************************************/
#include "Matrixnt.h"
Matrix4f::Matrix4f()
{
}
Matrix4f::~Matrix4f()
{
}
void Matrix4f::SetIndentify()
{
for(int i = 0; i < 4; i++)
{
int offset = i * 4;
for(int j = 0; j < 4; j++)
{
if(i == j)
m_mat[offset + j] = 1.0;
else
m_mat[offset + j] = 0.0;
}
}
}
void Matrix4f::operator =(Matrix3f mat)
{
for(int i = 0; i < 3; i++)
{
int r1 = i * 4;
int r2 = i * 3;
for(int j = 0; j < 3; j++)
{
m_mat[r1 + j] = mat.m_mat[r2 + j];
}
}
}
Matrix3f::Matrix3f()
{
}
Matrix3f::~Matrix3f()
{
}
void Matrix3f::SetIndentify()
{
for(int i = 0; i < 3; i++)
{
int offset = i * 3;
for(int j = 0; j < 3; j++)
{
if(i == j)
m_mat[offset + j] = 1.0;
else
m_mat[offset + j] = 0.0;
}
}
}
void Matrix3f::operator =(Matrix3f mat)
{
for(int i = 0; i < 9; i++)
{
m_mat[i] = mat.m_mat[i];
}
}
void Matrix3f::RightProduct_cm(Matrix3f mat)
{
float temp[9];
// for(int i = 0; i < 3; i++)
// {
// int r = i * 3;
// for(int j = 0; j < 3; j++)
// {
// temp[r + j] = 0.0;
// for(int k = 0; k < 3; k++)
// {
// temp[r + j] += m_mat[r + k] * mat.m_mat[k * 3 +j];
// }
// }
// }
temp[0] = m_mat[0] * mat.m_mat[0] + m_mat[3] * mat.m_mat[1] + m_mat[6] * mat.m_mat[2];
temp[3] = m_mat[0] * mat.m_mat[3] + m_mat[3] * mat.m_mat[4] + m_mat[6] * mat.m_mat[5];
temp[6] = m_mat[0] * mat.m_mat[6] + m_mat[3] * mat.m_mat[7] + m_mat[6] * mat.m_mat[8];
temp[1] = m_mat[1] * mat.m_mat[0] + m_mat[4] * mat.m_mat[1] + m_mat[7] * mat.m_mat[2];
temp[4] = m_mat[1] * mat.m_mat[3] + m_mat[4] * mat.m_mat[4] + m_mat[7] * mat.m_mat[5];
temp[7] = m_mat[1] * mat.m_mat[6] + m_mat[4] * mat.m_mat[7] + m_mat[7] * mat.m_mat[8];
temp[2] = m_mat[2] * mat.m_mat[0] + m_mat[5] * mat.m_mat[1] + m_mat[8] * mat.m_mat[2];
temp[5] = m_mat[2] * mat.m_mat[3] + m_mat[5] * mat.m_mat[4] + m_mat[8] * mat.m_mat[5];
temp[8] = m_mat[2] * mat.m_mat[6] + m_mat[5] * mat.m_mat[7] + m_mat[8] * mat.m_mat[8];
for(int i = 0; i < 9; i++)
{
m_mat[i] = temp[i];
}
}