diff options
author | Julian T <julian@jtle.dk> | 2020-08-13 20:06:29 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-08-13 20:06:29 +0200 |
commit | 5b0b916c561f602723b9ae80f5462a7939b652a1 (patch) | |
tree | 6ee419f0dd1649b2c329585551f06a555a631db8 /src/vector.cpp | |
parent | 690b72664ca8d471f5c117f6ed87aeae2de0a208 (diff) |
Pathtracing working with defuse and emissive lighting
Diffstat (limited to 'src/vector.cpp')
-rw-r--r-- | src/vector.cpp | 28 |
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; +} |