1 | /* graphene-euler.h: Euler angles |
2 | * |
3 | * SPDX-License-Identifier: MIT |
4 | * |
5 | * Copyright 2014 Emmanuele Bassi |
6 | * |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | * of this software and associated documentation files (the "Software"), to deal |
9 | * in the Software without restriction, including without limitation the rights |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 | * copies of the Software, and to permit persons to whom the Software is |
12 | * furnished to do so, subject to the following conditions: |
13 | * |
14 | * The above copyright notice and this permission notice shall be included in |
15 | * all copies or substantial portions of the Software. |
16 | * |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | * THE SOFTWARE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #if !defined(GRAPHENE_H_INSIDE) && !defined(GRAPHENE_COMPILATION) |
29 | #error "Only graphene.h can be included directly." |
30 | #endif |
31 | |
32 | #include "graphene-types.h" |
33 | #include "graphene-vec3.h" |
34 | |
35 | GRAPHENE_BEGIN_DECLS |
36 | |
37 | /** |
38 | * graphene_euler_order_t: |
39 | * @GRAPHENE_EULER_ORDER_DEFAULT: Rotate in the default order; the |
40 | * default order is one of the following enumeration values |
41 | * @GRAPHENE_EULER_ORDER_XYZ: Rotate in the X, Y, and Z order. Deprecated in |
42 | * Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SXYZ |
43 | * @GRAPHENE_EULER_ORDER_YZX: Rotate in the Y, Z, and X order. Deprecated in |
44 | * Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SYZX |
45 | * @GRAPHENE_EULER_ORDER_ZXY: Rotate in the Z, X, and Y order. Deprecated in |
46 | * Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SZXY |
47 | * @GRAPHENE_EULER_ORDER_XZY: Rotate in the X, Z, and Y order. Deprecated in |
48 | * Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SXZY |
49 | * @GRAPHENE_EULER_ORDER_YXZ: Rotate in the Y, X, and Z order. Deprecated in |
50 | * Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SYXZ |
51 | * @GRAPHENE_EULER_ORDER_ZYX: Rotate in the Z, Y, and X order. Deprecated in |
52 | * Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SZYX |
53 | * @GRAPHENE_EULER_ORDER_SXYZ: Defines a static rotation along the X, Y, and Z axes (Since: 1.10) |
54 | * @GRAPHENE_EULER_ORDER_SXYX: Defines a static rotation along the X, Y, and X axes (Since: 1.10) |
55 | * @GRAPHENE_EULER_ORDER_SXZY: Defines a static rotation along the X, Z, and Y axes (Since: 1.10) |
56 | * @GRAPHENE_EULER_ORDER_SXZX: Defines a static rotation along the X, Z, and X axes (Since: 1.10) |
57 | * @GRAPHENE_EULER_ORDER_SYZX: Defines a static rotation along the Y, Z, and X axes (Since: 1.10) |
58 | * @GRAPHENE_EULER_ORDER_SYZY: Defines a static rotation along the Y, Z, and Y axes (Since: 1.10) |
59 | * @GRAPHENE_EULER_ORDER_SYXZ: Defines a static rotation along the Y, X, and Z axes (Since: 1.10) |
60 | * @GRAPHENE_EULER_ORDER_SYXY: Defines a static rotation along the Y, X, and Y axes (Since: 1.10) |
61 | * @GRAPHENE_EULER_ORDER_SZXY: Defines a static rotation along the Z, X, and Y axes (Since: 1.10) |
62 | * @GRAPHENE_EULER_ORDER_SZXZ: Defines a static rotation along the Z, X, and Z axes (Since: 1.10) |
63 | * @GRAPHENE_EULER_ORDER_SZYX: Defines a static rotation along the Z, Y, and X axes (Since: 1.10) |
64 | * @GRAPHENE_EULER_ORDER_SZYZ: Defines a static rotation along the Z, Y, and Z axes (Since: 1.10) |
65 | * @GRAPHENE_EULER_ORDER_RZYX: Defines a relative rotation along the Z, Y, and X axes (Since: 1.10) |
66 | * @GRAPHENE_EULER_ORDER_RXYX: Defines a relative rotation along the X, Y, and X axes (Since: 1.10) |
67 | * @GRAPHENE_EULER_ORDER_RYZX: Defines a relative rotation along the Y, Z, and X axes (Since: 1.10) |
68 | * @GRAPHENE_EULER_ORDER_RXZX: Defines a relative rotation along the X, Z, and X axes (Since: 1.10) |
69 | * @GRAPHENE_EULER_ORDER_RXZY: Defines a relative rotation along the X, Z, and Y axes (Since: 1.10) |
70 | * @GRAPHENE_EULER_ORDER_RYZY: Defines a relative rotation along the Y, Z, and Y axes (Since: 1.10) |
71 | * @GRAPHENE_EULER_ORDER_RZXY: Defines a relative rotation along the Z, X, and Y axes (Since: 1.10) |
72 | * @GRAPHENE_EULER_ORDER_RYXY: Defines a relative rotation along the Y, X, and Y axes (Since: 1.10) |
73 | * @GRAPHENE_EULER_ORDER_RYXZ: Defines a relative rotation along the Y, X, and Z axes (Since: 1.10) |
74 | * @GRAPHENE_EULER_ORDER_RZXZ: Defines a relative rotation along the Z, X, and Z axes (Since: 1.10) |
75 | * @GRAPHENE_EULER_ORDER_RXYZ: Defines a relative rotation along the X, Y, and Z axes (Since: 1.10) |
76 | * @GRAPHENE_EULER_ORDER_RZYZ: Defines a relative rotation along the Z, Y, and Z axes (Since: 1.10) |
77 | * |
78 | * Specify the order of the rotations on each axis. |
79 | * |
80 | * The %GRAPHENE_EULER_ORDER_DEFAULT value is special, and is used |
81 | * as an alias for one of the other orders. |
82 | * |
83 | * Since: 1.2 |
84 | */ |
85 | typedef enum { |
86 | GRAPHENE_EULER_ORDER_DEFAULT = -1, |
87 | |
88 | /* Deprecated */ |
89 | GRAPHENE_EULER_ORDER_XYZ = 0, |
90 | GRAPHENE_EULER_ORDER_YZX, |
91 | GRAPHENE_EULER_ORDER_ZXY, |
92 | GRAPHENE_EULER_ORDER_XZY, |
93 | GRAPHENE_EULER_ORDER_YXZ, |
94 | GRAPHENE_EULER_ORDER_ZYX, |
95 | |
96 | /* Static (extrinsic) coordinate axes */ |
97 | GRAPHENE_EULER_ORDER_SXYZ, |
98 | GRAPHENE_EULER_ORDER_SXYX, |
99 | GRAPHENE_EULER_ORDER_SXZY, |
100 | GRAPHENE_EULER_ORDER_SXZX, |
101 | GRAPHENE_EULER_ORDER_SYZX, |
102 | GRAPHENE_EULER_ORDER_SYZY, |
103 | GRAPHENE_EULER_ORDER_SYXZ, |
104 | GRAPHENE_EULER_ORDER_SYXY, |
105 | GRAPHENE_EULER_ORDER_SZXY, |
106 | GRAPHENE_EULER_ORDER_SZXZ, |
107 | GRAPHENE_EULER_ORDER_SZYX, |
108 | GRAPHENE_EULER_ORDER_SZYZ, |
109 | |
110 | /* Relative (intrinsic) coordinate axes */ |
111 | GRAPHENE_EULER_ORDER_RZYX, |
112 | GRAPHENE_EULER_ORDER_RXYX, |
113 | GRAPHENE_EULER_ORDER_RYZX, |
114 | GRAPHENE_EULER_ORDER_RXZX, |
115 | GRAPHENE_EULER_ORDER_RXZY, |
116 | GRAPHENE_EULER_ORDER_RYZY, |
117 | GRAPHENE_EULER_ORDER_RZXY, |
118 | GRAPHENE_EULER_ORDER_RYXY, |
119 | GRAPHENE_EULER_ORDER_RYXZ, |
120 | GRAPHENE_EULER_ORDER_RZXZ, |
121 | GRAPHENE_EULER_ORDER_RXYZ, |
122 | GRAPHENE_EULER_ORDER_RZYZ |
123 | } graphene_euler_order_t; |
124 | |
125 | /** |
126 | * graphene_euler_t: |
127 | * |
128 | * Describe a rotation using Euler angles. |
129 | * |
130 | * The contents of the #graphene_euler_t structure are private |
131 | * and should never be accessed directly. |
132 | * |
133 | * Since: 1.2 |
134 | */ |
135 | struct _graphene_euler_t |
136 | { |
137 | /*< private >*/ |
138 | GRAPHENE_PRIVATE_FIELD (graphene_vec3_t, angles); |
139 | GRAPHENE_PRIVATE_FIELD (graphene_euler_order_t, order); |
140 | }; |
141 | |
142 | GRAPHENE_AVAILABLE_IN_1_2 |
143 | graphene_euler_t * graphene_euler_alloc (void); |
144 | GRAPHENE_AVAILABLE_IN_1_2 |
145 | void graphene_euler_free (graphene_euler_t *e); |
146 | |
147 | GRAPHENE_AVAILABLE_IN_1_2 |
148 | graphene_euler_t * graphene_euler_init (graphene_euler_t *e, |
149 | float x, |
150 | float y, |
151 | float z); |
152 | GRAPHENE_AVAILABLE_IN_1_2 |
153 | graphene_euler_t * graphene_euler_init_with_order (graphene_euler_t *e, |
154 | float x, |
155 | float y, |
156 | float z, |
157 | graphene_euler_order_t order); |
158 | GRAPHENE_AVAILABLE_IN_1_2 |
159 | graphene_euler_t * graphene_euler_init_from_matrix (graphene_euler_t *e, |
160 | const graphene_matrix_t *m, |
161 | graphene_euler_order_t order); |
162 | GRAPHENE_AVAILABLE_IN_1_2 |
163 | graphene_euler_t * graphene_euler_init_from_quaternion (graphene_euler_t *e, |
164 | const graphene_quaternion_t *q, |
165 | graphene_euler_order_t order); |
166 | GRAPHENE_AVAILABLE_IN_1_2 |
167 | graphene_euler_t * graphene_euler_init_from_vec3 (graphene_euler_t *e, |
168 | const graphene_vec3_t *v, |
169 | graphene_euler_order_t order); |
170 | GRAPHENE_AVAILABLE_IN_1_2 |
171 | graphene_euler_t * graphene_euler_init_from_euler (graphene_euler_t *e, |
172 | const graphene_euler_t *src); |
173 | GRAPHENE_AVAILABLE_IN_1_10 |
174 | graphene_euler_t * graphene_euler_init_from_radians (graphene_euler_t *e, |
175 | float x, |
176 | float y, |
177 | float z, |
178 | graphene_euler_order_t order); |
179 | |
180 | GRAPHENE_AVAILABLE_IN_1_2 |
181 | bool graphene_euler_equal (const graphene_euler_t *a, |
182 | const graphene_euler_t *b); |
183 | |
184 | GRAPHENE_AVAILABLE_IN_1_2 |
185 | float graphene_euler_get_x (const graphene_euler_t *e); |
186 | GRAPHENE_AVAILABLE_IN_1_2 |
187 | float graphene_euler_get_y (const graphene_euler_t *e); |
188 | GRAPHENE_AVAILABLE_IN_1_2 |
189 | float graphene_euler_get_z (const graphene_euler_t *e); |
190 | GRAPHENE_AVAILABLE_IN_1_2 |
191 | graphene_euler_order_t graphene_euler_get_order (const graphene_euler_t *e); |
192 | |
193 | GRAPHENE_AVAILABLE_IN_1_10 |
194 | float graphene_euler_get_alpha (const graphene_euler_t *e); |
195 | GRAPHENE_AVAILABLE_IN_1_10 |
196 | float graphene_euler_get_beta (const graphene_euler_t *e); |
197 | GRAPHENE_AVAILABLE_IN_1_10 |
198 | float graphene_euler_get_gamma (const graphene_euler_t *e); |
199 | |
200 | GRAPHENE_AVAILABLE_IN_1_2 |
201 | void graphene_euler_to_vec3 (const graphene_euler_t *e, |
202 | graphene_vec3_t *res); |
203 | GRAPHENE_AVAILABLE_IN_1_2 |
204 | void graphene_euler_to_matrix (const graphene_euler_t *e, |
205 | graphene_matrix_t *res); |
206 | GRAPHENE_AVAILABLE_IN_1_10 |
207 | void graphene_euler_to_quaternion (const graphene_euler_t *e, |
208 | graphene_quaternion_t *res); |
209 | |
210 | GRAPHENE_AVAILABLE_IN_1_2 |
211 | void graphene_euler_reorder (const graphene_euler_t *e, |
212 | graphene_euler_order_t order, |
213 | graphene_euler_t *res); |
214 | |
215 | GRAPHENE_END_DECLS |
216 | |