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 | |
35 | GRAPHENE_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 | */ |
47 | struct _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 | |
56 | GRAPHENE_AVAILABLE_IN_1_0 |
57 | graphene_quaternion_t * graphene_quaternion_alloc (void); |
58 | GRAPHENE_AVAILABLE_IN_1_0 |
59 | void graphene_quaternion_free (graphene_quaternion_t *q); |
60 | |
61 | GRAPHENE_AVAILABLE_IN_1_0 |
62 | graphene_quaternion_t * graphene_quaternion_init (graphene_quaternion_t *q, |
63 | float x, |
64 | float y, |
65 | float z, |
66 | float w); |
67 | GRAPHENE_AVAILABLE_IN_1_0 |
68 | graphene_quaternion_t * graphene_quaternion_init_identity (graphene_quaternion_t *q); |
69 | GRAPHENE_AVAILABLE_IN_1_0 |
70 | graphene_quaternion_t * graphene_quaternion_init_from_quaternion (graphene_quaternion_t *q, |
71 | const graphene_quaternion_t *src); |
72 | GRAPHENE_AVAILABLE_IN_1_0 |
73 | graphene_quaternion_t * graphene_quaternion_init_from_vec4 (graphene_quaternion_t *q, |
74 | const graphene_vec4_t *src); |
75 | GRAPHENE_AVAILABLE_IN_1_0 |
76 | graphene_quaternion_t * graphene_quaternion_init_from_matrix (graphene_quaternion_t *q, |
77 | const graphene_matrix_t *m); |
78 | GRAPHENE_AVAILABLE_IN_1_0 |
79 | graphene_quaternion_t * graphene_quaternion_init_from_angles (graphene_quaternion_t *q, |
80 | float deg_x, |
81 | float deg_y, |
82 | float deg_z); |
83 | GRAPHENE_AVAILABLE_IN_1_4 |
84 | graphene_quaternion_t * graphene_quaternion_init_from_radians (graphene_quaternion_t *q, |
85 | float rad_x, |
86 | float rad_y, |
87 | float rad_z); |
88 | GRAPHENE_AVAILABLE_IN_1_0 |
89 | graphene_quaternion_t * graphene_quaternion_init_from_angle_vec3 (graphene_quaternion_t *q, |
90 | float angle, |
91 | const graphene_vec3_t *axis); |
92 | GRAPHENE_AVAILABLE_IN_1_2 |
93 | graphene_quaternion_t * graphene_quaternion_init_from_euler (graphene_quaternion_t *q, |
94 | const graphene_euler_t *e); |
95 | |
96 | GRAPHENE_AVAILABLE_IN_1_0 |
97 | void graphene_quaternion_to_vec4 (const graphene_quaternion_t *q, |
98 | graphene_vec4_t *res); |
99 | GRAPHENE_AVAILABLE_IN_1_0 |
100 | void graphene_quaternion_to_matrix (const graphene_quaternion_t *q, |
101 | graphene_matrix_t *m); |
102 | GRAPHENE_AVAILABLE_IN_1_2 |
103 | void graphene_quaternion_to_angles (const graphene_quaternion_t *q, |
104 | float *deg_x, |
105 | float *deg_y, |
106 | float *deg_z); |
107 | GRAPHENE_AVAILABLE_IN_1_4 |
108 | void graphene_quaternion_to_radians (const graphene_quaternion_t *q, |
109 | float *rad_x, |
110 | float *rad_y, |
111 | float *rad_z); |
112 | GRAPHENE_AVAILABLE_IN_1_0 |
113 | void graphene_quaternion_to_angle_vec3 (const graphene_quaternion_t *q, |
114 | float *angle, |
115 | graphene_vec3_t *axis); |
116 | |
117 | GRAPHENE_AVAILABLE_IN_1_0 |
118 | bool graphene_quaternion_equal (const graphene_quaternion_t *a, |
119 | const graphene_quaternion_t *b); |
120 | GRAPHENE_AVAILABLE_IN_1_0 |
121 | float graphene_quaternion_dot (const graphene_quaternion_t *a, |
122 | const graphene_quaternion_t *b); |
123 | GRAPHENE_AVAILABLE_IN_1_0 |
124 | void graphene_quaternion_invert (const graphene_quaternion_t *q, |
125 | graphene_quaternion_t *res); |
126 | GRAPHENE_AVAILABLE_IN_1_0 |
127 | void graphene_quaternion_normalize (const graphene_quaternion_t *q, |
128 | graphene_quaternion_t *res); |
129 | GRAPHENE_AVAILABLE_IN_1_0 |
130 | void graphene_quaternion_slerp (const graphene_quaternion_t *a, |
131 | const graphene_quaternion_t *b, |
132 | float factor, |
133 | graphene_quaternion_t *res); |
134 | GRAPHENE_AVAILABLE_IN_1_10 |
135 | void graphene_quaternion_multiply (const graphene_quaternion_t *a, |
136 | const graphene_quaternion_t *b, |
137 | graphene_quaternion_t *res); |
138 | GRAPHENE_AVAILABLE_IN_1_10 |
139 | void graphene_quaternion_scale (const graphene_quaternion_t *q, |
140 | float factor, |
141 | graphene_quaternion_t *res); |
142 | GRAPHENE_AVAILABLE_IN_1_10 |
143 | void graphene_quaternion_add (const graphene_quaternion_t *a, |
144 | const graphene_quaternion_t *b, |
145 | graphene_quaternion_t *res); |
146 | |
147 | GRAPHENE_END_DECLS |
148 | |