forked from alecmyers/MyAHRS
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathVector.h
78 lines (67 loc) · 1.83 KB
/
Vector.h
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
/*
*/
#ifndef VECTOR_H
#define VECTOR_H
typedef struct{
int x, y, z;
} intVector;
class Vector3 {
public:
float x, y, z;
Vector3 ();
Vector3 (float X, float Y, float Z);
const Vector3 cross(const Vector3 &other) const;
const Vector3 operator + (const Vector3 &other) const;
const Vector3 operator - (const Vector3 &other) const;
const Vector3 operator * (const float scale) const;
const Vector3 operator / (const float scale) const;
const Vector3 operator / (const Vector3 &other) const;
Vector3 & operator *= (const float scale);
Vector3 & operator /= (const float scale);
Vector3 & operator /= (const Vector3 &other);
Vector3 & operator += (const Vector3 &other);
Vector3 & operator -= (const Vector3 &other);
float magnitude();
const Vector3 normalize();
const Vector3 squared() const;
const float dot(const Vector3 &other) const;
void print();
};
class Vector2 {
public:
float u,v;
Vector2 ();
Vector2 (float A, float B);
const Vector2 operator + (const Vector2 &other) const;
const Vector2 operator - (const Vector2 &other) const;
void print();
};
class Matrix3 {
public:
Vector3 X, Y, Z;
Matrix3();
void rotate(Vector3 *v);
void unRotate(Vector3 *v);
void print();
};
class Matrix2 {
public:
float uu, uv, vu, vv;
Matrix2();
Matrix2(float A, float B, float C, float D);
const Matrix2 operator + (const Matrix2 &other) const;
const Matrix2 operator - (const Matrix2 &other) const;
const Matrix2 operator * (const float scale) const;
const Matrix2 operator * (const Matrix2 &other) const;
const Vector2 operator * (const Vector2 &vec) const;
const Matrix2 T() const;
const Matrix2 I() const;
void print();
};
#ifdef __cplusplus
extern "C"{
#endif
#ifdef __cplusplus
}
#endif
#endif // VECTOR_H