forked from leftspace89/pPlat
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrVectors.hpp
More file actions
68 lines (61 loc) · 914 Bytes
/
rVectors.hpp
File metadata and controls
68 lines (61 loc) · 914 Bytes
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
#pragma once
#ifndef RVECTOR
#define RVECTOR
class RVector3 : public D3DXVECTOR3
{
public:
RVector3()
{
x = 0;
y = 0;
z = 0;
}
RVector3(D3DXVECTOR3 vec)
{
x = vec.x;
y = vec.y;
z = vec.z;
}
RVector3(float X, float Y, float Z)
{
x = X;
y = Y;
z = Z;
}
RVector3(float X, float Z)
{
x = X;
y = 0;
z = Z;
}
float Length()
{
return (float)sqrt((x * x) + (y * y) + (z * z));
}
float Distance(RVector3 b)
{
RVector3 vector = RVector3(x - b.x, y - b.y, z - b.z);
return sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
}
D3DXVECTOR3 Normalize()
{
float length = Length();
if (length != 0)
{
float inv = 1.0f / length;
x *= inv;
y *= inv;
z *= inv;
}
return D3DXVECTOR3(x, y, z);
}
RVector3 perpendicularTo()
{
return RVector3(z, y, -x);
}
RVector3 To2D()
{
return RVector3(x, z,0);
}
};
#endif // kuçu korumasý