-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathVector3.cpp
57 lines (45 loc) · 1.13 KB
/
Vector3.cpp
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
#include "Precompiled.hpp"
#include "Vector3.hpp"
namespace Math
{
const Vector3 Vector3::ZERO(0.0f, 0.0f, 0.0f);
const Vector3 Vector3::UNIT_X(1.0f, 0.0f, 0.0f);
const Vector3 Vector3::UNIT_Y(0.0f, 1.0f, 0.0f);
const Vector3 Vector3::UNIT_Z(0.0f, 0.0f, 1.0f);
float Vector3::length() const
{
return XMVectorGetX(XMVector3Length(*this));
}
float Vector3::length_squared() const
{
return XMVectorGetX(XMVector3LengthSq(*this));
}
void Vector3::normalise()
{
*this = XMVector3Normalize(*this);
}
Vector3 Vector3::normalise() const
{
return Vector3(XMVector3Normalize(*this));
}
float Vector3::dot(const Vector3& v) const
{
return XMVectorGetX(XMVector3Dot(*this, v));
}
Vector3 Vector3::cross(const Vector3& v) const
{
return Vector3(XMVector3Cross(*this, v));
}
Vector3 Vector3::lerp(const Vector3& a, const Vector3& b, float t)
{
return Vector3(XMVectorLerp(a, b, t));
}
Vector3 Vector3::minimise(const Vector3& a, const Vector3& b)
{
return Vector3(XMVectorMin(a, b));
}
Vector3 Vector3::maximise(const Vector3& a, const Vector3& b)
{
return Vector3(XMVectorMax(a, b));
}
} // namespace Math