-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVector.h
62 lines (47 loc) · 1.57 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef VECTOR_H
#define VECTOR_H
#include "common.h"
#include "Point.h"
class Vector: public Point {
public:
// Constructor
Vector();
Vector(const RTdouble &);
Vector(const RTdouble &, const RTdouble &, const RTdouble &);
Vector(const Point &, const Point &);
// = operator
Vector & operator =(const Vector &);
// Copy Constructor
Vector(const Vector &);
// operators
// add
Vector operator +(const Vector &) const;
Vector & operator +=(const Vector &);
Point operator +(const Point &) const;
friend Point operator +(const Point &, const Vector &);
// subtract
Vector operator -() const;
Vector operator -(const Vector &) const;
Vector & operator -=(const Vector &);
// multiply (scale)
Vector operator *(const RTdouble &) const;
friend Vector operator *(const RTdouble &, const Vector &);
Vector & operator *=(const RTdouble &);
// divide (scale)
Vector operator /(const RTdouble &) const;
Vector & operator /=(const RTdouble &);
// scalar product
RTdouble operator *(const Vector &) const;
// vector product
Vector operator ^(const Vector &) const;
// normalization
void normalize(); // / w
Vector unit() const; // return unit vector
// length
RTdouble length() const;
// instantiation
void print(const string &) const;
};
Point operator -(const Point &, const Vector &);
Vector operator -(const Point&, const Point &);
#endif