From 1f335dffc9a08edebacd42a28fb4b8fe994e8fcb Mon Sep 17 00:00:00 2001 From: Martin Opat Date: Thu, 9 Jan 2025 20:36:14 +0100 Subject: [PATCH] Added support for float multiplication of vec3 --- src/linalg/vec.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/linalg/vec.h b/src/linalg/vec.h index f4bf332..06a1b38 100644 --- a/src/linalg/vec.h +++ b/src/linalg/vec.h @@ -20,6 +20,12 @@ struct Vec3 { // TODO: Maybe make this into a class ... maybe __host__ __device__ Vec3 operator*(double b) const { return Vec3::init(x * b, y * b, z * b); } __host__ __device__ Vec3& operator*=(double b) { x *= b; y *= b; z *= b; return *this; } + __host__ __device__ Vec3 operator*(float b) const { return Vec3::init(x * b, y * b, z * b); } + __host__ __device__ Vec3& operator*=(float b) { x *= b; y *= b; z *= b; return *this; } + friend __host__ __device__ Vec3 operator*(float a, const Vec3& b) { + return Vec3::init(a * b.x, a * b.y, a * b.z); + } + __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); }