-
Notifications
You must be signed in to change notification settings - Fork 2
/
TVector.cpp
74 lines (69 loc) · 1.15 KB
/
TVector.cpp
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
#include "TVector.h"
TVector::TVector(void)
{
A[0] = A[0] =0;
LENGTH = 2;
}
TVector::~TVector(void)
{
}
TVector::TVector(int length)
{
LENGTH = length;
}
TVector::TVector(float a0,float a1)
{
LENGTH = 2;
A[0] = a0;
A[1] = a1;
}
TVector operator +(const TVector& s1,const TVector& s2)
{
TVector c;
for (int i = 0; i<s1.LENGTH; i++)
{
c.A[i] = s1.A[i]+s2.A[i];
}
c.LENGTH = s1.LENGTH;
return c;
}
TVector operator *(const TVector& s1,const TVector& s2)
{
TVector c;
for (int i = 0; i<s1.LENGTH; i++)
{
c.A[i] = s1.A[i]*s2.A[i];
}
c.LENGTH = s1.LENGTH;
return c;
}
TVector operator *(const TVector& s1,const float& s2)
{
TVector c;
for (int i = 0; i<s1.LENGTH; i++)
{
c.A[i] = s1.A[i]*s2;
}
c.LENGTH = s1.LENGTH;
return c;
}
TVector operator *(const float& s1,const TVector& s2)
{
TVector c;
for (int i = 0; i<s2.LENGTH; i++)
{
c.A[i] = s2.A[i]*s1;
}
c.LENGTH = s2.LENGTH;
return c;
}
TVector operator -(const TVector& s1,const TVector& s2)
{
TVector c;
for (int i = 0; i<s1.LENGTH; i++)
{
c.A[i] = s1.A[i]-s2.A[i];
}
c.LENGTH = s1.LENGTH;
return c;
}