-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvectormath.h
More file actions
101 lines (81 loc) · 1.61 KB
/
Copy pathvectormath.h
File metadata and controls
101 lines (81 loc) · 1.61 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once
struct Vector
{
float x, y, z;
Vector();
Vector(const Vector& v);
Vector(float x, float y, float z);
Vector(float f);
virtual ~Vector();
inline float length2();
inline float length();
float normalize();
Vector normalized();
Vector& operator =(const Vector& v);
Vector& operator +=(const Vector& v);
Vector& operator -=(const Vector& v);
Vector& operator *=(float f);
Vector& operator /=(float f);
Vector operator -() const;
};
float dot(Vector v1, Vector v2);
Vector cross(Vector v1, Vector v2);
inline Vector operator +(const Vector& v1, const Vector& v2)
{
return Vector(v1.x + v2.x,
v1.y + v2.y,
v1.z + v2.z);
}
inline Vector operator -(const Vector& v1, const Vector& v2)
{
return Vector(v1.x - v2.x,
v1.y - v2.y,
v1.z - v2.z);
}
inline Vector operator *(const Vector& v1, const Vector& v2)
{
return Vector(v1.x * v2.x,
v1.y * v2.y,
v1.z * v2.z);
}
inline Vector operator *(const Vector& v, float f)
{
return Vector(v.x * f,
v.y * f,
v.z * f);
}
inline Vector operator *(float f, const Vector& v)
{
return Vector(f * v.x,
f * v.y,
f * v.z);
}
inline Vector operator /(const Vector& v1, const Vector& v2)
{
return Vector(v1.x / v2.x,
v1.y / v2.y,
v1.z / v2.z);
}
inline Vector operator /(const Vector& v, float f)
{
return Vector(v.x / f,
v.y / f,
v.z / f);
}
inline Vector operator /(float f, const Vector& v)
{
return Vector(f / v.x,
f / v.y,
f / v.z);
}
typedef Vector Point;
struct Vector2
{
float u, v;
Vector2();
Vector2(const Vector2& v);
Vector2(float u, float v);
Vector2(float f);
virtual ~Vector2();
Vector2& operator =(const Vector2& v);
};