-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathvec.h
More file actions
67 lines (54 loc) · 1.51 KB
/
Copy pathvec.h
File metadata and controls
67 lines (54 loc) · 1.51 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef VEC2_H
#define VEC2_H
#include <string>
struct vec2f
{
float x, y;
vec2f operator+(const vec2f &rhs) const;
vec2f operator-(const vec2f &rhs) const;
vec2f operator*(float rhs) const;
vec2f operator/(float rhs) const;
vec2f& operator+=(const vec2f &rhs);
vec2f& operator-=(const vec2f &rhs);
vec2f& operator*=(float rhs);
vec2f& operator/=(float rhs);
bool operator==(const vec2f &rhs) const;
bool operator<(const vec2f &rhs) const; // (lexicographic comparison only)
float dot(const vec2f &rhs) const;
float length() const;
vec2f normalise() const;
std::string toString();
vec2f(float _x = 0, float _y = 0);
};
inline vec2f::vec2f(float _x, float _y)
{
x = _x;
y = _y;
}
typedef vec2f vec2;
struct vec3f
{
float x, y, z;
vec3f operator+(const vec3f &rhs) const;
vec3f operator-(const vec3f &rhs) const;
vec3f operator*(float rhs) const;
vec3f operator/(float rhs) const;
vec3f& operator+=(const vec3f &rhs);
vec3f& operator-=(const vec3f &rhs);
vec3f& operator*=(float rhs);
vec3f& operator/=(float rhs);
bool operator==(const vec3f &rhs) const;
bool operator<(const vec3f &rhs) const; // (lexicographic comparison only)
float dot(const vec3f &rhs) const;
float length() const;
vec3f normalise() const;
std::string toString();
vec3f(float _x = 0, float _y = 0, float _z = 0);
};
inline vec3f::vec3f(float _x, float _y, float _z)
{
x = _x;
y = _y;
z = _z;
}
#endif // VEC2_H