aboutsummaryrefslogtreecommitdiff
path: root/src/vector.cpp
diff options
context:
space:
mode:
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;
+}