1/* graphene-quaternion.h: Quaternion
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-vec4.h"
34
35GRAPHENE_BEGIN_DECLS
36
37/**
38 * graphene_quaternion_t:
39 *
40 * A quaternion.
41 *
42 * The contents of the #graphene_quaternion_t structure are private
43 * and should never be accessed directly.
44 *
45 * Since: 1.0
46 */
47struct _graphene_quaternion_t
48{
49 /*< private >*/
50 GRAPHENE_PRIVATE_FIELD (float, x);
51 GRAPHENE_PRIVATE_FIELD (float, y);
52 GRAPHENE_PRIVATE_FIELD (float, z);
53 GRAPHENE_PRIVATE_FIELD (float, w);
54};
55
56GRAPHENE_AVAILABLE_IN_1_0
57graphene_quaternion_t * graphene_quaternion_alloc (void);
58GRAPHENE_AVAILABLE_IN_1_0
59void graphene_quaternion_free (graphene_quaternion_t *q);
60
61GRAPHENE_AVAILABLE_IN_1_0
62graphene_quaternion_t * graphene_quaternion_init (graphene_quaternion_t *q,
63 float x,
64 float y,
65 float z,
66 float w);
67GRAPHENE_AVAILABLE_IN_1_0
68graphene_quaternion_t * graphene_quaternion_init_identity (graphene_quaternion_t *q);
69GRAPHENE_AVAILABLE_IN_1_0
70graphene_quaternion_t * graphene_quaternion_init_from_quaternion (graphene_quaternion_t *q,
71 const graphene_quaternion_t *src);
72GRAPHENE_AVAILABLE_IN_1_0
73graphene_quaternion_t * graphene_quaternion_init_from_vec4 (graphene_quaternion_t *q,
74 const graphene_vec4_t *src);
75GRAPHENE_AVAILABLE_IN_1_0
76graphene_quaternion_t * graphene_quaternion_init_from_matrix (graphene_quaternion_t *q,
77 const graphene_matrix_t *m);
78GRAPHENE_AVAILABLE_IN_1_0
79graphene_quaternion_t * graphene_quaternion_init_from_angles (graphene_quaternion_t *q,
80 float deg_x,
81 float deg_y,
82 float deg_z);
83GRAPHENE_AVAILABLE_IN_1_4
84graphene_quaternion_t * graphene_quaternion_init_from_radians (graphene_quaternion_t *q,
85 float rad_x,
86 float rad_y,
87 float rad_z);
88GRAPHENE_AVAILABLE_IN_1_0
89graphene_quaternion_t * graphene_quaternion_init_from_angle_vec3 (graphene_quaternion_t *q,
90 float angle,
91 const graphene_vec3_t *axis);
92GRAPHENE_AVAILABLE_IN_1_2
93graphene_quaternion_t * graphene_quaternion_init_from_euler (graphene_quaternion_t *q,
94 const graphene_euler_t *e);
95
96GRAPHENE_AVAILABLE_IN_1_0
97void graphene_quaternion_to_vec4 (const graphene_quaternion_t *q,
98 graphene_vec4_t *res);
99GRAPHENE_AVAILABLE_IN_1_0
100void graphene_quaternion_to_matrix (const graphene_quaternion_t *q,
101 graphene_matrix_t *m);
102GRAPHENE_AVAILABLE_IN_1_2
103void graphene_quaternion_to_angles (const graphene_quaternion_t *q,
104 float *deg_x,
105 float *deg_y,
106 float *deg_z);
107GRAPHENE_AVAILABLE_IN_1_4
108void graphene_quaternion_to_radians (const graphene_quaternion_t *q,
109 float *rad_x,
110 float *rad_y,
111 float *rad_z);
112GRAPHENE_AVAILABLE_IN_1_0
113void graphene_quaternion_to_angle_vec3 (const graphene_quaternion_t *q,
114 float *angle,
115 graphene_vec3_t *axis);
116
117GRAPHENE_AVAILABLE_IN_1_0
118bool graphene_quaternion_equal (const graphene_quaternion_t *a,
119 const graphene_quaternion_t *b);
120GRAPHENE_AVAILABLE_IN_1_0
121float graphene_quaternion_dot (const graphene_quaternion_t *a,
122 const graphene_quaternion_t *b);
123GRAPHENE_AVAILABLE_IN_1_0
124void graphene_quaternion_invert (const graphene_quaternion_t *q,
125 graphene_quaternion_t *res);
126GRAPHENE_AVAILABLE_IN_1_0
127void graphene_quaternion_normalize (const graphene_quaternion_t *q,
128 graphene_quaternion_t *res);
129GRAPHENE_AVAILABLE_IN_1_0
130void graphene_quaternion_slerp (const graphene_quaternion_t *a,
131 const graphene_quaternion_t *b,
132 float factor,
133 graphene_quaternion_t *res);
134GRAPHENE_AVAILABLE_IN_1_10
135void graphene_quaternion_multiply (const graphene_quaternion_t *a,
136 const graphene_quaternion_t *b,
137 graphene_quaternion_t *res);
138GRAPHENE_AVAILABLE_IN_1_10
139void graphene_quaternion_scale (const graphene_quaternion_t *q,
140 float factor,
141 graphene_quaternion_t *res);
142GRAPHENE_AVAILABLE_IN_1_10
143void graphene_quaternion_add (const graphene_quaternion_t *a,
144 const graphene_quaternion_t *b,
145 graphene_quaternion_t *res);
146
147GRAPHENE_END_DECLS
148

source code of gtk/subprojects/graphene/include/graphene-quaternion.h