-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvector3d.h
31 lines (27 loc) · 1 KB
/
vector3d.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
#ifndef VECTOR_3D
#define VECTOR_3D
#include <iostream>
#include <cmath>
#include <assert.h>
using namespace std;
class vector3d {
private:
public:
double x, y, z;
vector3d(double x , double y, double z) : x(x), y(y), z(z) { }
vector3d() : x(0), y(0), z(0) {}
//vector3d(vector3d vec) : x(vec.x), y(vec.y), z(vec.z) {}
friend ostream& operator<<(ostream& os, const vector3d& vec);
friend vector3d operator+(const vector3d& a, const vector3d& b);
friend vector3d operator-(const vector3d& a, const vector3d& b);
friend vector3d operator*(const vector3d& a, const double& b);
friend vector3d operator*(const double& a, const vector3d& b);
friend double operator*(const vector3d& a, const vector3d& b);
friend vector3d operator%(const vector3d& a, const vector3d& b);
friend bool operator==(const vector3d& lhs, const vector3d& rhs);
friend bool operator!=(const vector3d& lhs, const vector3d& rhs);
double operator[](int i);
vector3d normalize(double r = 1);
double length();
};
#endif