1 | #pragma once
|
---|
2 |
|
---|
3 | #include <vrmath/vrLinmath.h>
|
---|
4 | #include <vrmath/vrVector3f.h>
|
---|
5 | #include <vrmath/vrVector4f.h>
|
---|
6 |
|
---|
7 | class vrMatrix4x4f;
|
---|
8 |
|
---|
9 | class LmExport vrVector4f {
|
---|
10 | public :
|
---|
11 | float x, y, z, w;
|
---|
12 |
|
---|
13 | public :
|
---|
14 | vrVector4f() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {}
|
---|
15 | vrVector4f(const vrVector4f& v4) : x(v4.x), y(v4.y), z(v4.z) , w(v4.w) {}
|
---|
16 | vrVector4f(const vrVector3f& v3, float w1) : x(v3.x), y(v3.y), z(v3.z) , w(w1) {}
|
---|
17 | vrVector4f(float x1, float y1, float z1, float w1) : x(x1), y(y1), z(z1), w(w1) {}
|
---|
18 |
|
---|
19 | void set(float x1, float y1, float z1, float w1);
|
---|
20 | void set(const vrVector3f& v, float w);
|
---|
21 | void set(const vrVector4f& v4);
|
---|
22 | void divideByW();
|
---|
23 | float dot(const vrVector4f& vec);
|
---|
24 | void mult(const vrMatrix4x4f& mat, const vrVector4f& vec);
|
---|
25 | void mult(const vrMatrix4x4f& mat);
|
---|
26 |
|
---|
27 | void transform(const vrVector4f& v, const vrMatrix4x4f& m);
|
---|
28 | };
|
---|
29 |
|
---|
30 | inline void vrVector4f::divideByW()
|
---|
31 | {
|
---|
32 | if (w != 0)
|
---|
33 | {
|
---|
34 | x /= w; y /= w; z /= w;
|
---|
35 | w = 1.0f;
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | inline void vrVector4f::set(float x1, float y1, float z1, float w1)
|
---|
40 | {
|
---|
41 | x = x1;
|
---|
42 | y = y1;
|
---|
43 | z = z1;
|
---|
44 | w = w1;
|
---|
45 | }
|
---|
46 |
|
---|
47 | inline void vrVector4f::set(const vrVector4f& v4)
|
---|
48 | {
|
---|
49 | x = v4.x;
|
---|
50 | y = v4.y;
|
---|
51 | z = v4.z;
|
---|
52 | w = v4.w;
|
---|
53 | }
|
---|
54 |
|
---|
55 | inline void vrVector4f::set(const vrVector3f& v, float w1)
|
---|
56 | {
|
---|
57 | x = v.x;
|
---|
58 | y = v.y;
|
---|
59 | z = v.z;
|
---|
60 | w = w1;
|
---|
61 | }
|
---|
62 |
|
---|
63 | inline float vrVector4f::dot(const vrVector4f& vec)
|
---|
64 | {
|
---|
65 | return x * vec.x + y * vec.y + z * vec.z + w * vec.w;
|
---|
66 | }
|
---|