aboutsummaryrefslogtreecommitdiff
path: root/src/vector.cpp
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-08-13 20:06:29 +0200
committerJulian T <julian@jtle.dk>2020-08-13 20:06:29 +0200
commit5b0b916c561f602723b9ae80f5462a7939b652a1 (patch)
tree6ee419f0dd1649b2c329585551f06a555a631db8 /src/vector.cpp
parent690b72664ca8d471f5c117f6ed87aeae2de0a208 (diff)
Pathtracing working with defuse and emissive lighting
Diffstat (limited to 'src/vector.cpp')
-rw-r--r--src/vector.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/vector.cpp b/src/vector.cpp
index 1e4f5a1..51d8e2e 100644
--- a/src/vector.cpp
+++ b/src/vector.cpp
@@ -52,6 +52,13 @@ Vec3d Vec3d::operator+(const Vec3d &vec) const {
);
}
+Vec3d& Vec3d::operator+=(const Vec3d &vec) {
+ m_x += vec.m_x;
+ m_y += vec.m_y;
+ m_z += vec.m_z;
+ return *this;
+}
+
Vec3d Vec3d::operator-(const Vec3d &vec) const {
return Vec3d(
m_x - vec.m_x,
@@ -76,3 +83,24 @@ Vec3d Vec3d::operator*(double op) const {
m_z * op
);
}
+
+Vec3d Vec3d::operator*(const Vec3d &vec) const {
+ return Vec3d(
+ m_x * vec.m_x,
+ m_y * vec.m_y,
+ m_z * vec.m_z
+ );
+}
+
+Vec3d Vec3d::operator/(double op) const {
+ return Vec3d(
+ m_x / op,
+ m_y / op,
+ m_z / op
+ );
+}
+
+std::ostream& operator<<(std::ostream &out, const Vec3d &v){
+ out << "[ " << v.m_x << ", " << v.m_y << ", " << v.m_z << " ]";
+ return out;
+}