KurusView  1.0
MVector.h
Go to the documentation of this file.
1 
9 #ifndef INC_KURUSVIEW_MVECTOR_H
10 #define INC_KURUSVIEW_MVECTOR_H
11 
12 #include <iostream>
13 #include <fstream>
14 #include <cmath>
15 #include <vector>
16 
17 class MMatrix;
18 
19 class MVector {
27  friend std::ostream &operator<<(std::ostream &os, MVector &obj);
28 
36  friend std::ofstream &operator<<(std::ofstream &os, MVector &obj);
37 
38 public:
42  MVector();
43 
47  MVector(double x, double y, double z);
48 
52  MVector(double x, double y, double z, long int id);
53 
55  ~MVector() = default;
56 
61  double getX() const;
62 
67  double getY() const;
68 
73  double getZ() const;
74 
78  void setX(double x);
79 
83  void setY(double y);
84 
88  void setZ(double z);
89 
95  MVector operator+(const MVector &obj) const;
96 
102  MVector operator-(const MVector &obj) const;
103 
109  MVector operator*(const MVector &obj) const;
110 
116  MVector operator*(const double &scalar) const;
117 
123  MVector operator/(const double &scalar) const;
124 
129  double getModulus() const;
130 
135  long int getID() const;
136 
137  const double &operator[](int index) const;
138 
139  bool operator==(const MVector &v) const;
140 
141  bool operator!=(const MVector &v) const;
142 
143 private:
145  double x;
146  double y;
147  double z;
148 
150  long int MVectorID;
151 };
152 
159 double dotProduct(MVector v1, MVector v2);
160 
167 double scalarTripleProduct(MVector dotA, MVector xB, MVector xC);
168 
169 #endif //INC_KURUSVIEW_MVECTOR_H
MVector operator+(const MVector &obj) const
operator+ - overloads the + operator to add two vectors directly together
Definition: MVector.cpp:80
double dotProduct(MVector v1, MVector v2)
dotProduct - finds the dot product between two vectors
Definition: MVector.cpp:208
double getModulus() const
getModulus - obtains the modulus of an MVector
Definition: MVector.cpp:67
void setY(double y)
setY - Sets y-coordinate of vector
Definition: MVector.cpp:57
void setZ(double z)
setZ - Sets z-coordinate of vector
Definition: MVector.cpp:62
double getX() const
getX (accessor)
Definition: MVector.cpp:37
~MVector()=default
default destructor
long int getID() const
getID
Definition: MVector.cpp:74
MVector operator/(const double &scalar) const
operator/ - overloads the / operator to divide a vector by a scalar
Definition: MVector.cpp:142
double scalarTripleProduct(MVector dotA, MVector xB, MVector xC)
Scalar Triple Product - https://en.wikipedia.org/wiki/Triple_product.
Definition: MVector.cpp:214
MVector operator*(const MVector &obj) const
operator* - overloads the * operator to find the cross product between two vectors ...
Definition: MVector.cpp:121
friend std::ostream & operator<<(std::ostream &os, MVector &obj)
classic friend overloaded ostream operator<< declaration - prints MVector properties to stdout in hum...
Definition: MVector.cpp:5
MVector operator-(const MVector &obj) const
operator- - overloads the - operator to add two vectors directly together
Definition: MVector.cpp:100
double getY() const
getY (accessor)
Definition: MVector.cpp:42
void setX(double x)
setX - Sets x-coordinate of vector
Definition: MVector.cpp:52
double getZ() const
getZ (accessor)
Definition: MVector.cpp:47
Definition: MMatrix.h:16
Definition: MVector.h:19
MVector()
default constructor - Initializes coordinates to zero
Definition: MVector.cpp:22