FreeWRL / FreeX3D
4.3.0
quaternion.h
1
/*
2
3
4
Quaternion ???
5
6
*/
7
8
/****************************************************************************
9
This file is part of the FreeWRL/FreeX3D Distribution.
10
11
Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12
13
FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14
it under the terms of the GNU Lesser Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25
****************************************************************************/
26
27
28
#ifndef __FREEWRL_QUATERNION_H__
29
#define __FREEWRL_QUATERNION_H__
30
31
32
#define DELTA 0.0001
33
34
/* definitions for mapping matrix in OpenGL format to standard math */
35
#define MAT00 mat[0]
36
#define MAT01 mat[1]
37
#define MAT02 mat[2]
38
#define MAT03 mat[3]
39
#define MAT10 mat[4]
40
#define MAT11 mat[5]
41
#define MAT12 mat[6]
42
#define MAT13 mat[7]
43
#define MAT20 mat[8]
44
#define MAT21 mat[9]
45
#define MAT22 mat[10]
46
#define MAT23 mat[11]
47
#define MAT30 mat[12]
48
#define MAT31 mat[13]
49
#define MAT32 mat[14]
50
#define MAT33 mat[15]
51
52
/* definitions for "standard" matrix representation to map to OpenGL */
53
#define MATHEMATICS_MAT00 mat[0]
54
#define MATHEMATICS_MAT01 mat[4]
55
#define MATHEMATICS_MAT02 mat[8]
56
#define MATHEMATICS_MAT03 mat[12]
57
#define MATHEMATICS_MAT10 mat[1]
58
#define MATHEMATICS_MAT11 mat[5]
59
#define MATHEMATICS_MAT12 mat[9]
60
#define MATHEMATICS_MAT13 mat[13]
61
#define MATHEMATICS_MAT20 mat[2]
62
#define MATHEMATICS_MAT21 mat[6]
63
#define MATHEMATICS_MAT22 mat[10]
64
#define MATHEMATICS_MAT23 mat[14]
65
#define MATHEMATICS_MAT30 mat[3]
66
#define MATHEMATICS_MAT31 mat[7]
67
#define MATHEMATICS_MAT32 mat[11]
68
#define MATHEMATICS_MAT33 mat[15]
69
70
typedef
struct
quaternion
{
71
double
w;
72
double
x;
73
double
y;
74
double
z;
75
}
Quaternion
;
76
void
77
matrix_to_quaternion (
Quaternion
*quat,
double
*mat) ;
78
void
79
quaternion_to_matrix (
double
*mat,
Quaternion
*quat) ;
80
81
void
scale_to_matrix (
double
*mat,
struct
point_XYZ
*scale);
82
83
void
84
vrmlrot_to_quaternion(
Quaternion
*quat,
85
const
double
x,
86
const
double
y,
87
const
double
z,
88
const
double
a);
89
void
vrmlrot4d_to_quaternion(
Quaternion
*quat,
const
double
*xyza);
90
void
vrmlrot4f_to_quaternion(
Quaternion
*quat,
const
float
*xyza);
91
void
92
quaternion_to_vrmlrot(
const
Quaternion
*quat,
93
double
*x,
94
double
*y,
95
double
*z,
96
double
*a);
97
void
quaternion_to_vrmlrot4d(
const
Quaternion
*quat,
double
*xyza);
98
99
void
quaternion_to_vrmlrot4f(
const
Quaternion
*quat,
float
*rot);
100
void
101
quaternion_conjugate(
Quaternion
*quat);
102
103
void
104
quaternion_inverse(
Quaternion
*ret,
105
const
Quaternion
*quat);
106
107
double
108
quaternion_norm(
const
Quaternion
*quat);
109
110
void
111
quaternion_normalize(
Quaternion
*quat);
112
113
void
114
quaternion_add(
Quaternion
*ret,
115
const
Quaternion
*q1,
116
const
Quaternion
*q2);
117
118
void
119
quaternion_multiply(
Quaternion
*ret,
120
const
Quaternion
*q1,
121
const
Quaternion
*q2);
122
123
void
124
quaternion_scalar_multiply(
Quaternion
*quat,
125
const
double
s);
126
127
void
128
quaternion_rotation(
struct
point_XYZ
*ret,
129
const
Quaternion
*quat,
130
const
struct
point_XYZ
*v);
131
double
*
132
quaternion_rotationd(
double
*ret,
Quaternion
*quat,
double
*v);
133
134
float
*
135
quaternion_rotation3f(
float
*ret,
Quaternion
*quat,
float
*v);
136
137
void
138
quaternion_togl(
Quaternion
*quat);
139
140
void
141
quaternion_set(
Quaternion
*ret,
142
const
Quaternion
*quat);
143
144
void
145
quaternion_slerp(
Quaternion
*ret,
146
const
Quaternion
*q1,
147
const
Quaternion
*q2,
148
const
double
t);
149
void
quaternion_print(
const
Quaternion
*quat,
char
* description );
150
void
double2quat(
Quaternion
*quat,
double
*quat4);
151
void
quat2double(
double
*quat4,
Quaternion
*quat);
152
void
quat2euler(
double
*rxyz,
int
iaxis_halfcircle,
Quaternion
*q);
153
void
quat2yawpitch(
double
*ypr,
Quaternion
*q);
154
void
euler2quat1(
Quaternion
*qout,
double
*axyz);
155
void
euler2quat(
Quaternion
*qout,
double
heading,
double
attitude,
double
bank);
156
157
double
rad2deg(
double
rad);
158
void
loadIdentityMatrix (
double
*);
159
void
vrmlrot_multiply(
float
* ret,
float
*a,
float
*b);
160
void
vrmlrot_normalize(
float
*ret);
161
162
#endif
/* __FREEWRL_QUATERNION_H__ */
point_XYZ
Definition
Structs.h:34
quaternion
Definition
quaternion.h:70
src
lib
scenegraph
quaternion.h
Generated by
1.11.0