-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVector.h
43 lines (37 loc) · 1.09 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
#include "math.h"
#ifndef _Vector_h_
#define _Vector_h_
#include <iostream>
using namespace std;
class Vector {
/*
Vector consists of a direction (x, y, z) (this is not a
unit vector!) and can return a calculated magnitude
*/
public:
Vector();
Vector(float x, float y, float z);
float getX() const;
float getY() const;
float getZ() const;
void setX(float n);
void setY(float n);
void setZ(float n);
float getMagnitude();
float dotProduct(Vector u);
Vector crossProduct(Vector u);
void normalize();
// operator overloading
Vector& operator +=(const Vector& rhs);
Vector& operator -=(const Vector& rhs);
const Vector operator +(const Vector& rhs) const;
const Vector operator -(const Vector& rhs) const;
const Vector operator *(const float scalar) const;
const Vector operator /(const float scalar) const;
private:
float x;
float y;
float z;
};
ostream& operator <<(ostream& outs, const Vector& vector);
#endif