-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVec3.h
More file actions
38 lines (32 loc) · 1.73 KB
/
Copy pathVec3.h
File metadata and controls
38 lines (32 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <cstdint>
#pragma once
class alignas(16) Vec3 {
public:
float x, y, z;
__host__ __device__ Vec3(float x=0,float y=0,float z=0);
__host__ __device__ Vec3 unitVector() const;
__host__ __device__ float magnitude() const;
__host__ __device__ Vec3 operator+(const Vec3& other) const;
__host__ __device__ Vec3 operator+(const float other) const;
__host__ __device__ Vec3 operator-(const Vec3& other) const;
__host__ __device__ Vec3 operator-(const float other) const;
__host__ __device__ Vec3 operator*(const float other) const;
__host__ __device__ Vec3 operator*(const Vec3& other) const;
__host__ __device__ Vec3 operator/(const float other) const;
__host__ __device__ Vec3 operator/(const Vec3& other) const;
__host__ __device__ Vec3 operator-() const;
__host__ __device__ Vec3& operator+=(const Vec3& other);
__host__ __device__ Vec3& operator+=(const float other);
__host__ __device__ Vec3& operator-=(const Vec3& other);
__host__ __device__ Vec3& operator-=(const float other);
__host__ __device__ Vec3& operator*=(const float other);
__host__ __device__ Vec3& operator*=(const Vec3& other);
__host__ __device__ float& operator[](const uint& other);
__host__ __device__ const float& operator[](const uint& other) const;
__host__ __device__ float dot(const Vec3& other) const;
__host__ __device__ Vec3 cross(const Vec3& other) const;
__host__ __device__ uint32_t toUint32() const;
friend std::ostream& operator<<(std::ostream& os, const Vec3& vec);
friend __device__ void atomicAddVec3(Vec3& address, const Vec3& val);
};