OSDN Git Service

12935e4c8d2379f0235cb36c0b0da4ea8974df1d
[meshio/meshio.git] / include / la.h
1 #ifndef MESH_IO_LA_H_INCLUDED
2 #define MESH_IO_LA_H_INCLUDED
3
4 #include <ostream>
5
6 namespace meshio {
7 namespace la {
8 /**
9  * \e$B@~7ABe?t\e(B(Linear Algebra)
10  */
11
12 struct Vector2
13 {
14         float x;
15         float y;
16
17         Vector2()
18         {}
19
20         Vector2(float _x, float _y)
21                 : x(_x), y(_y)
22                 {}
23 };
24 #ifndef SWIG
25 inline std::ostream &operator<<(std::ostream &os, const Vector2 &rhs)
26 {
27         return os
28                 << '[' << rhs.x << ',' << rhs.y << ']';
29 }
30 #endif
31
32
33 struct Vector3
34 {
35         float x;
36         float y;
37         float z;
38
39         Vector3()
40         {}
41
42         Vector3(float _x, float _y, float _z)
43                 : x(_x), y(_y), z(_z)
44                 {}
45
46         bool operator==(const Vector3 &rhs)const
47         {
48                 return x==rhs.x && y==rhs.y && z==rhs.z;
49         }
50 };
51 #ifndef SWIG
52 inline std::ostream &operator<<(std::ostream &os, const Vector3 &rhs)
53 {
54         return os
55                 << '[' << rhs.x << ',' << rhs.y << ',' << rhs.z << ']';
56 }
57 #endif
58
59
60 struct Vector4
61 {
62         float x;
63         float y;
64         float z;
65         float w;
66
67         Vector4()
68         {}
69
70         Vector4(float _x, float _y, float _z, float _w)
71                 : x(_x), y(_y), z(_z), w(_w)
72                 {}
73 };
74 #ifndef SWIG
75 inline std::ostream &operator<<(std::ostream &os, const Vector4 &rhs)
76 {
77         return os
78                 << '[' << rhs.x << ',' << rhs.y << ',' << rhs.z << ',' << rhs.w << ']';
79 }
80 #endif
81
82
83 struct Quaternion
84 {
85         float x;
86         float y;
87         float z;
88         float w;
89
90         Quaternion()
91         {}
92
93         Quaternion(float _x, float _y, float _z, float _w)
94                 : x(_x), y(_y), z(_z), w(_w)
95                 {}
96
97         float dot(const Quaternion &rhs)
98         {
99                 return x*rhs.x + y*rhs.y + z*rhs.z + w*rhs.w;
100         }
101 };
102 #ifndef SWIG
103 inline std::ostream &operator<<(std::ostream &os, const Quaternion &rhs)
104 {
105         return os
106                 << '[' << rhs.x << ',' << rhs.y << ',' << rhs.z << ',' << rhs.w << ']';
107 }
108 #endif
109
110
111 }
112 }
113
114 #endif // MESH_IO_LA_H_INCLUDED