-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvector.h
56 lines (40 loc) · 1.05 KB
/
vector.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef VECTOR_H
#define VECTOR_H
#include <cmath>
#include <cstdlib>
#ifdef _EE
#include <gsKit.h>
#endif
#include <stdint.h>
class Vec3f {
public:
static Vec3f reflect(const Vec3f& I, const Vec3f& J);
struct VecComponents
{
float x;
float y;
float z;
float w;
};
VecComponents vector;
float &x;
float &y;
float &z;
constexpr Vec3f () : vector({}), x(vector.x), y(vector.y), z(vector.z) {}
constexpr Vec3f (float _x, float _y, float _z) : vector({_x, _y, _z, .0f}),
x(vector.x), y(vector.y), z(vector.z) {}
constexpr Vec3f (const Vec3f &other) : vector(other.vector), x(vector.x), y(vector.y),
z(vector.z) {}
float norm();
float dot(const Vec3f &other) const;
Vec3f operator*(float k) const;
Vec3f& operator=(const Vec3f &other);
Vec3f normalize();
float operator[](int index);
#ifdef _EE
uint32_t asGsColor();
#endif
};
Vec3f operator+(const Vec3f& a, const Vec3f& b);
Vec3f operator-(const Vec3f& a, const Vec3f& b);
#endif // VECTOR_H