-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector4D.cpp
More file actions
53 lines (44 loc) · 1.04 KB
/
Vector4D.cpp
File metadata and controls
53 lines (44 loc) · 1.04 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
#include "Vector4D.h"
Vector4D::Vector4D()
{
}
Vector4D::~Vector4D()
{
}
Vector4D::Vector4D(float x, float y, float z, float w)
{
this->x = x;
this->y = y;
this->z = z;
this->w = w;
}
Vector4D::Vector4D(const Vector4D* vector)
{
this->x = vector->x;
this->y = vector->y;
this->z = vector->z;
this->w = vector->w;
}
void Vector4D::cross(Vector4D v1, Vector4D v2, Vector4D v3)
{
this->x = v1.y * (v2.z * v3.w - v3.z * v2.w) - v1.z * (v2.y * v3.w - v3.y * v2.w) + v1.w * (v2.y * v3.z - v2.z * v3.y);
this->y = -(v1.x * (v2.z * v3.w - v3.z * v2.w) - v1.z * (v2.x * v3.w - v3.x * v2.w) + v1.w * (v2.x * v3.z - v3.x * v2.z));
this->z = v1.x * (v2.y * v3.w - v3.y * v2.w) - v1.y * (v2.x * v3.w - v3.x * v2.w) + v1.w * (v2.x * v3.y - v3.x * v2.y);
this->w = -(v1.x * (v2.y * v3.z - v3.y * v2.z) - v1.y * (v2.x * v3.z - v3.x * v2.z) + v1.z * (v2.x * v3.y - v3.x * v2.y));
}
float Vector4D::getX()
{
return this->x;
}
float Vector4D::getY()
{
return this->y;
}
float Vector4D::getZ()
{
return this->z;
}
float Vector4D::getW()
{
return this->w;
}