-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyVec4d.cpp
More file actions
53 lines (45 loc) · 811 Bytes
/
myVec4d.cpp
File metadata and controls
53 lines (45 loc) · 811 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
42
43
44
45
46
47
48
49
50
51
52
53
#include "myVec4d.h"
myVec4d::myVec4d()
{
for(int i = 0;i < 4;++i)
data[i] = 0;
}
myVec4d::myVec4d(double _x,double _y,double _z,double _w)
{
data[0] = _x;
data[1] = _y;
data[2] = _z;
data[3] = _w;
}
myVec4d::~myVec4d()
{
}
myVec4d operator+(const myVec4d& a,const myVec4d& b)
{
myVec4d ret;
for(int i = 0;i < 4;++i)
ret.data[i] = a.data[i] * b.data[i];
return ret;
}
Mat4 operator*(const myVec4d& a,const myVec4d& b)
{
Mat4 ret;
for(int i = 0;i < 4;++i)
for(int j = 0;j < 4;++j)
ret.mat[i][j] = a.data[i] * b.data[j];
return ret;
}
double cal( const myVec4d& a, const myVec4d& b)
{
double ret = 0.0;
for(int i = 0;i < 4;i++)
{
ret += a.data[i] * b.data[i];
}
return ret;
}
void myVec4d::operator=(const myVec4d& v)
{
for(int i = 0;i < 4;i++)
this->data[i] = v.data[i];
}