summaryrefslogtreecommitdiff
path: root/vec.h
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-04-12 13:03:05 +0800
committerKeuin <[email protected]>2022-04-12 13:03:05 +0800
commit60a3e2aedda225591f10a360575250b201aadd53 (patch)
tree09cfb81976dc8b2d8e4f050ac3745ee72686aa6f /vec.h
parentafad858dada4d2735d5408a4eca064fb605e4578 (diff)
Add vec3::mod2.
Diffstat (limited to 'vec.h')
-rw-r--r--vec.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/vec.h b/vec.h
index 017b0a9..bf40e7d 100644
--- a/vec.h
+++ b/vec.h
@@ -71,6 +71,11 @@ struct vec3 {
}
}
+ // Squared module
+ T mod2() const {
+ return x * x + y * y + z * z;
+ }
+
vec3 unit_vec() const {
return *this * (1.0 / norm());
}