Added func. for length of vec3

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

View File

@ -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;