.Simulation
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Pages
DataReader
Vector3.h
1
// Vector3.h - Vector 3D Struct Declaration
2
// Written By Jesse Z. Zhong
3
#ifndef __Vector_3D_H__
4
#define __Vector_3D_H__
5
#pragma region Includes
6
#include "stdafx.h"
7
using namespace
std;
8
#pragma endregion
9
namespace
DataReader {
13
template
<
typename
DATA_TYPE =
double
>
14
struct
Vector3
{
15
19
Vector3
(
const
Vector3<DATA_TYPE>
& source);
20
24
Vector3
(DATA_TYPE x = 0,
25
DATA_TYPE y = 0, DATA_TYPE z = 0);
26
27
// The scalar components of a vector.
28
DATA_TYPE X, Y, Z;
29
33
static
Vector3
Zero();
34
38
const
Vector3
& operator=(
const
Vector3
& source);
39
43
const
Vector3
& operator+(
const
Vector3
& operand);
44
48
const
Vector3
& operator-(
const
Vector3
& operand);
49
};
50
51
// Out stream operator overload for vector 3D.
52
template
<
typename
T>
53
ostream& operator<<(ostream& out, const Vector3<T>& data) {
54
out << data.X <<
", "
<< data.Y <<
", "
<< data.Z;
55
return
out;
56
}
57
58
template
<
typename
DATA_TYPE>
59
Vector3<DATA_TYPE>::Vector3
(
const
Vector3<DATA_TYPE>
& source) {
60
X = source.X;
61
Y = source.Y;
62
Z = source.Z;
63
}
64
65
template
<
typename
DATA_TYPE>
66
Vector3<DATA_TYPE>::Vector3
(DATA_TYPE x, DATA_TYPE y, DATA_TYPE z) {
67
X = x;
68
Y = y;
69
Z = z;
70
}
71
72
template
<
typename
DATA_TYPE>
73
static
Vector3<DATA_TYPE>
Vector3<DATA_TYPE>::Zero
() {
74
return
Vector3
();
75
}
76
77
template
<
typename
DATA_TYPE>
78
const
Vector3<DATA_TYPE>
&
Vector3<DATA_TYPE>::operator=
(
const
Vector3
& source) {
79
X = source.X;
80
Y = source.Y;
81
Z = source.Z;
82
return
*
this
;
83
}
84
85
template
<
typename
DATA_TYPE>
86
const
Vector3<DATA_TYPE>
&
Vector3<DATA_TYPE>::operator+
(
const
Vector3
& operand) {
87
X += operand.X;
88
Y += operand.Y;
89
Z += operand.Z;
90
return
*
this
;
91
}
92
93
template
<
typename
DATA_TYPE>
94
const
Vector3<DATA_TYPE>
&
Vector3<DATA_TYPE>::operator-
(
const
Vector3
& operand) {
95
X -= operand.X;
96
Y -= operand.Y;
97
Z -= operand.Z;
98
return
*
this
;
99
}
100
}
101
#endif // End : Vector3D
DataReader::Vector3
3D Vector Structure
Definition:
Vector3.h:14
Generated on Thu Dec 19 2013 08:13:08 for .Simulation by
1.8.5