Added support for float multiplication of vec3

This commit is contained in:
Martin Opat 2025-01-09 20:36:14 +01:00
parent fc2488c578
commit 1f335dffc9
1 changed files with 6 additions and 0 deletions

View File

@ -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) 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*=(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__ 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 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); }