-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPoint.cpp
More file actions
38 lines (26 loc) · 785 Bytes
/
Copy pathPoint.cpp
File metadata and controls
38 lines (26 loc) · 785 Bytes
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
#include <cmath>
#include "Point.h"
point point::operator + (point const &pt) {
point p(pt.x + x , pt.y + y, pt.z + z);
return(p);
}
point point::operator - (point const &pt) {
point p(x - pt.x , y - pt.y, z - pt.z);
return(p);
}
double point::operator * (point const &pt) {
return( x * pt.x + y * pt.y + z * pt.z );
}
point point::operator / (double scalar) {
point p(x / scalar , y / scalar , z / scalar);
return(p);
}
point point::operator * (double scalar) {
point p(x * scalar , y * scalar , z * scalar);
return(p);
}
ray::ray( point p, point d ) : pos(p), dir(d) {
// normalize direciton vector
double norm = 1.0 / std::sqrt( dir.x * dir.x + dir.y * dir.y + dir.z * dir.z );
dir.x *= norm; dir.y *= norm; dir.z *= norm;
}