diff options
Diffstat (limited to 'src/math/vector.h')
-rw-r--r-- | src/math/vector.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/math/vector.h b/src/math/vector.h index 41f11a8..65fc2f9 100644 --- a/src/math/vector.h +++ b/src/math/vector.h @@ -24,6 +24,7 @@ #include "func.h" #include <cmath> +#include <sstream> // Math module namespace @@ -202,6 +203,16 @@ struct Vector return Vector(left.x / right, left.y / right, left.z / right); } + + //! Returns a string "[x, y, z]" + inline std::string ToString() const + { + std::stringstream s; + s.precision(3); + s << "[" << x << ", " << y << ", " << z << "]"; + return s.str(); + } + }; // struct Point //! Checks if two vectors are equal within given \a tolerance |