aboutsummaryrefslogtreecommitdiffstats
path: root/src/vec3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vec3.cpp')
-rw-r--r--src/vec3.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/vec3.cpp b/src/vec3.cpp
index 8e27a98..8f7a720 100644
--- a/src/vec3.cpp
+++ b/src/vec3.cpp
@@ -1,4 +1,5 @@
#include <cmath>
+#include <limits.h>
#include "vec3.hpp"
#include "utils.hpp"
@@ -40,6 +41,19 @@ vec3& vec3::operator/=(float numerator) {
return *this;
}
+float vec3::operator[](int axis) {
+ switch (axis) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ case 2:
+ return z;
+ default:
+ return std::numeric_limits<float>::infinity();
+ }
+}
+
float vec3::length() const {
return sqrt(length_sq());
}