-
Notifications
You must be signed in to change notification settings - Fork 1
/
Point3D.h
71 lines (48 loc) · 1.49 KB
/
Point3D.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
63
64
65
66
67
68
69
70
71
#ifndef __POINT3D__
#define __POINT3D__
#include "Matrix.h"
#include "Vector3D.h"
class Point3D
{
public:
double x, y, z;
Point3D();
Point3D(const double a);
Point3D(const double a, const double b, const double c);
Point3D(const Point3D& p);
~Point3D();
Point3D& operator= (const Point3D& p);
Point3D operator- (void) const;
Vector3D operator- (const Point3D& p) const;
Point3D operator+ (const Vector3D& v) const;
Point3D operator- (const Vector3D& v) const;
Point3D operator* (const double a) const;
double d_squared(const Point3D& p) const;
double distance(const Point3D& p) const;
};
inline Point3D Point3D::operator- (void) const {
return (Point3D(-x, -y, -z));
}
inline Vector3D Point3D::operator- (const Point3D& p) const {
return (Vector3D(x - p.x, y - p.y, z - p.z));
}
inline Point3D Point3D::operator+ (const Vector3D& v) const {
return (Point3D(x + v.x, y + v.y, z + v.z));
}
inline Point3D Point3D::operator- (const Vector3D& v) const {
return (Point3D(x - v.x, y - v.y, z - v.z));
}
inline Point3D Point3D::operator* (const double a) const {
return (Point3D(x * a, y * a, z * a));
}
inline double Point3D::d_squared(const Point3D& p) const {
return ( (x - p.x) * (x - p.x)
+ (y - p.y) * (y - p.y)
+ (z - p.z) * (z - p.z) );
}
Point3D operator* (double a, const Point3D& p);
inline Point3D operator* (double a, const Point3D& p) {
return(Point3D(a * p.x, a * p.y, a * p.z));
}
Point3D operator* (const Matrix& mat, const Point3D& p);
#endif