From 09220ced2586acbd6bb38fd1bf68b25a55f440f0 Mon Sep 17 00:00:00 2001 From: Martin Opat Date: Thu, 9 Jan 2025 20:36:43 +0100 Subject: [PATCH] Added func. for length of vec3 --- src/linalg/vec.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/linalg/vec.h b/src/linalg/vec.h index 06a1b38..281709a 100644 --- a/src/linalg/vec.h +++ b/src/linalg/vec.h @@ -30,6 +30,7 @@ struct Vec3 { // TODO: Maybe make this into a class ... maybe __host__ __device__ double dot(const Vec3& b) const { return x * b.x + y * b.y + z * b.z; } __host__ __device__ Vec3 cross(const Vec3& b) const { return Vec3::init(y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x); } __host__ __device__ Vec3 normalize() const { double len = sqrt(x * x + y * y + z * z); return Vec3::init(x / len, y / len, z / len); } + __host__ __device__ double length() const { return sqrt(x * x + y * y + z * z); } }; typedef Vec3 Point3;