Revision: | 1254 |
Committed: | Wed Jun 9 16:16:33 2004 UTC (20 years, 11 months ago) by tim |
File size: | 1180 byte(s) |
Log Message: | 1. adding some useful math classes(Mat3x3d, Vector3d, Quaternion, Euler3) these classes use anonymous union and struct to support double[3], double[3][3] and double[4] 2. adding roll constraint algorithm |
# | User | Rev | Content |
---|---|---|---|
1 | tim | 1254 | #ifndef _QUATERNION_H_ |
2 | #define _QUATERNION_H_ | ||
3 | #include <iostream> | ||
4 | using namespace std; | ||
5 | |||
6 | class Mat3x3d; | ||
7 | class Euler3; | ||
8 | class Vector3d; | ||
9 | |||
10 | class Quaternion{ | ||
11 | public: | ||
12 | Quaternion(){ | ||
13 | } | ||
14 | |||
15 | Quaternion(double x, double y, double z, double w){ | ||
16 | this->x = x; | ||
17 | this->y = y; | ||
18 | this->z = z; | ||
19 | this->w = w; | ||
20 | } | ||
21 | |||
22 | Quaternion(const Quaternion& q){ | ||
23 | this->x = q.x; | ||
24 | this->y = q.y; | ||
25 | this->z = q.z; | ||
26 | this->w = q.w; | ||
27 | } | ||
28 | |||
29 | Quaternion(Mat3x3d& m); | ||
30 | |||
31 | Quaternion(const Euler3& e); | ||
32 | |||
33 | inline double& operator[](unsigned int i) { | ||
34 | switch (i){ | ||
35 | case 0: | ||
36 | return x; | ||
37 | case 1: | ||
38 | return y; | ||
39 | case 2: | ||
40 | return z; | ||
41 | case 3: | ||
42 | return w; | ||
43 | default: | ||
44 | cerr << "error in Quaternion::::operator[]" << endl | ||
45 | << "The method has been called with an illegal index i=" << i << "." << endl; | ||
46 | exit(1); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | Mat3x3d toRotationMatrix(); | ||
51 | Euler3 toEuler(); | ||
52 | |||
53 | union{ | ||
54 | struct{ | ||
55 | double x; | ||
56 | double y; | ||
57 | double z; | ||
58 | double w; | ||
59 | }; | ||
60 | double quat[4]; | ||
61 | }; | ||
62 | }; | ||
63 | |||
64 | #endif //end ifndef _QUATERNION_H_ |
Name | Value |
---|---|
svn:executable | * |