From 60a3e2aedda225591f10a360575250b201aadd53 Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 12 Apr 2022 13:03:05 +0800 Subject: Add vec3::mod2. --- vec.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'vec.h') 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()); } -- cgit v1.2.3