From 5b0b916c561f602723b9ae80f5462a7939b652a1 Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 13 Aug 2020 20:06:29 +0200 Subject: Pathtracing working with defuse and emissive lighting --- src/vector.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/vector.cpp') 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; +} -- cgit v1.2.3