Added a way to output vec2d in an easy way

This commit is contained in:
Karma Riuk 2023-03-14 21:45:44 +01:00
parent d0670178c0
commit 7a5bf13575

View File

@ -2,6 +2,7 @@
#define VEC2D_H_INCLUDED #define VEC2D_H_INCLUDED
#include <cmath> #include <cmath>
#include <ostream>
class vec2d { class vec2d {
public: public:
@ -67,6 +68,10 @@ public:
} }
}; };
static inline std::ostream& operator<<(std::ostream& os, vec2d& p) {
return os << '(' << p.x << ", " << p.y << ')';
}
static inline vec2d operator*(double l, const vec2d& v) { static inline vec2d operator*(double l, const vec2d& v) {
return vec2d{v.x * l, v.y * l}; return vec2d{v.x * l, v.y * l};
} }