-
Notifications
You must be signed in to change notification settings - Fork 7
/
vector.h
85 lines (69 loc) · 1.55 KB
/
vector.h
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
// Header gaurd
#ifndef VECTOR_H
#define VECTOR_H
// Vector class
class Vector {
// Public
public:
/*
Name: Constructor
Purpose: Allows setting vector components upon creation
*/
Vector(double x = 0, double y = 0, double z = 0, double e = 0);
/*
Name: Copy Constructor
Purpose: Initializes a copy of a vector
*/
Vector(Vector &value);
/*
Name: Get Length
Purpose: Returns length of vector
*/
double getLength() const;
/*
Name: Normalize
Purpose: Normalizes vector components
*/
void normalize();
/*
Name: Addition operator
Purpose: Allows adding vectors
*/
Vector operator+(const Vector &addend) const;
Vector &operator+=(const Vector &addend);
/*
Name: Subtraction operator
Purpose: Allows subtracting vectors
*/
Vector operator-(const Vector &subtrahend) const;
Vector &operator-=(const Vector &addend);
/*
Name: Multiplication operator
Purpose: Allows scaling a vector
*/
Vector operator*(double multiplier) const;
Vector &operator*=(double multiplier);
/*
Name: Division operator
Purpose: Allows shrinking a vector
*/
Vector operator/(double divisor) const;
Vector &operator/=(double divisor);
/*
Name: Subscript operator
Purpose: Allows addressing vector components
*/
const double& operator[](int index) const;
double& operator[](int index);
/*
Name: Assignment operator
Purpose: Allows copying a vector
*/
Vector &operator=(const Vector &vector);
// Vector components
double x;
double y;
double z;
double e;
};
#endif