13CAD
CAD-like software based on C++, Qt and VTK.
 All Classes Files Functions Variables Friends
vector3d.h
Go to the documentation of this file.
1 
8 #ifndef VECTOR_H
9 #define VECTOR_H
10 
11 #include <stdio.h>
12 #include <iostream>
13 
17 class Vector3D
18 {
19  friend class Matrix3x3;
20 
21  protected:
22  // Spatial coordinates
23 
27  double x;
28 
32  double y;
33 
37  double z;
38 
39  public:
40  Vector3D();
41  Vector3D(double x, double y, double z);
42  ~Vector3D();
43 
44  // Accessors
45 
49  double getX();
50 
54  double getY();
55 
59  double getZ();
60 
61  // Mutators
62 
66  void setX(double x);
67 
71  void setY(double y);
72 
76  void setZ(double z);
77 
78  // Operator overloading
79  // Note: rhs stands for right hand side
80 
84  Vector3D operator+(Vector3D rhsVector);
85 
89  Vector3D operator-(Vector3D rhsVector);
90 
94  friend bool operator==(const Vector3D &lhsVector, const Vector3D &rhsVector);
95 
99  double dot(Vector3D rhsVector);
100 
104  Vector3D cross(Vector3D rhsVector);
105 
109  Vector3D operator*(double scalar);
110 
114  friend Vector3D operator*(double scalar, Vector3D v);
115 
119  friend std::ostream &operator<<(std::ostream &os, Vector3D &v); // cout
120 
121  // Misc functions
122 
126  double distance(Vector3D &v2);
127 
132 };
133 
134 #endif /* VECTOR_H */
Vector3D cross(Vector3D rhsVector)
Definition: vector3d.cpp:112
void setX(double x)
Definition: vector3d.cpp:43
Definition: matrix.h:17
double z
Definition: vector3d.h:37
Vector3D operator+(Vector3D rhsVector)
Definition: vector3d.cpp:58
double dot(Vector3D rhsVector)
Definition: vector3d.cpp:103
friend std::ostream & operator<<(std::ostream &os, Vector3D &v)
Definition: vector3d.cpp:122
Vector3D midpoint(Vector3D &v2)
Definition: vector3d.cpp:139
Vector3D operator*(double scalar)
Definition: vector3d.cpp:85
double getY()
Definition: vector3d.cpp:33
double getZ()
Definition: vector3d.cpp:38
Definition: vector3d.h:17
void setZ(double z)
Definition: vector3d.cpp:53
double y
Definition: vector3d.h:32
double getX()
Definition: vector3d.cpp:28
void setY(double y)
Definition: vector3d.cpp:48
friend bool operator==(const Vector3D &lhsVector, const Vector3D &rhsVector)
Definition: vector3d.cpp:70
Vector3D operator-(Vector3D rhsVector)
Definition: vector3d.cpp:64
double distance(Vector3D &v2)
Definition: vector3d.cpp:127
double x
Definition: vector3d.h:27