CSCI 3081 - Drone Delivery System
vector.h
Go to the documentation of this file.
1 
7 #ifndef INC_VECTOR_H_
8 #define INC_VECTOR_H_
9 
10 /*******************************************************************************
11  * Includes
12  ******************************************************************************/
13 #include <vector> // Used for vector like vector3D and vector2D
14 #include <string>
15 #include <iostream>
16 #include <cmath>
17 #include <iomanip> // Used for set precision
18 
19 
20 namespace csci3081 {
21 /*******************************************************************************
22  * Class Definitions
23  ******************************************************************************/
31 class Vector {
32  protected:
33  float x,y,z;
34  public:
38  void SetX(float x_);
39 
43  void SetZ(float z_);
44 
48  float GetX() const {return x;};
49 
53  float GetZ() const {return z;};
54 
58  float GetY() const {return y;};
59 
63  float Magnitude();
64 
72  friend float DotProduct(const Vector& v1, const Vector& v2);
73 
81  friend float Distance(const Vector& v1, const Vector& v2);
82 
89  friend std::vector<float> toVectorFloat(Vector& v);
90 
98  bool operator == (const Vector&);
99 
103  virtual void Print() = 0;
104 };
105 
106 /*******************************************************************************
107  * Class Definitions
108  ******************************************************************************/
115 class Vector3D: public Vector {
116 
117  public:
125  Vector3D(float x_, float y_, float z_);
126 
132  Vector3D(std::vector<float> arg);
133 
138  Vector3D();
139 
146  Vector3D(const Vector3D&);
147 
152  void SetY(float y_);
153 
158  Vector3D operator +(const Vector3D&);
159 
164  Vector3D operator -(const Vector3D&);
165 
170  Vector3D operator *(float);
171 
176  Vector3D operator /(float);
177 
182  Vector3D& operator =(const Vector3D&);
183 
187  Vector3D Normalize();
188 
192  void Print();
193 
194  bool IsWithinXandZRange(const Vector3D&, float precision);
195 };
196 
197 /*******************************************************************************
198  * Class Definitions
199  ******************************************************************************/
206 class Vector2D: public Vector {
207  public:
212  Vector2D();
213 
219  Vector2D(std::vector<float> arg);
220 
227  Vector2D(float x_, float z_);
228 
235  Vector2D(const Vector2D&);
236 
241  Vector2D operator +(const Vector2D&);
242 
247  Vector2D operator -(const Vector2D&);
248 
253  Vector2D operator *(float);
254 
259  Vector2D operator /(float);
260 
265  Vector2D& operator =(const Vector2D&);
266 
270  Vector2D Normalize();
271 
275  void Print();
276 };
277 
283 Vector2D to2D(Vector3D&);
284 
290 Vector3D to3D(Vector2D&);
291 
298 Vector3D CrossProduct(const Vector& v1, const Vector& v2);
299 } // ending namepsace
300 
301 #endif /* INC_VECTOR_H_ */
bool operator==(const Vector &)
Convert vector distance to std::vector<float> instances.
Definition: vector.cc:20
void SetZ(float z_)
This function uses to set z coordinator of a vector instance.
Definition: vector.cc:12
friend std::vector< float > toVectorFloat(Vector &v)
Convert vector distance to std::vector<float> instances.
Definition: vector.cc:25
float GetZ() const
This function uses to get z coordinator of a vector instance.
Definition: vector.h:53
void SetX(float x_)
This function uses to set x coordinator of a vector instance.
Definition: vector.cc:8
Definition: asubject.cc:3
float z
Coordinates of a vector.
Definition: vector.h:33
This is the Vector2D class.
Definition: vector.h:206
This is the interface class for the Vector3D and Vector2D classes.
Definition: vector.h:31
friend float Distance(const Vector &v1, const Vector &v2)
Compute the distance (float variable) between two vectors instances.
Definition: vector.cc:188
float GetX() const
This function uses to get x coordinator of a vector instance.
Definition: vector.h:48
float GetY() const
This function uses to get y coordinator of a vector instance.
Definition: vector.h:58
virtual void Print()=0
Function to print the coordinate of a vector instance.
float Magnitude()
This function returns the magitude of a vector instance.
Definition: vector.cc:16
friend float DotProduct(const Vector &v1, const Vector &v2)
Compute the dot product (float variable) between two vectors instances.
Definition: vector.cc:184
This is the Vector3D class.
Definition: vector.h:115