1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
use crate::Matrix;
use crate::Vec3;
use crate::Vec4;
use glib::translate::*;
use std::mem;
glib::wrapper! {
pub struct Quaternion(BoxedInline<ffi::graphene_quaternion_t>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_quaternion_get_type(), ptr as *mut _) as *mut ffi::graphene_quaternion_t,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_quaternion_get_type(), ptr as *mut _),
type_ => || ffi::graphene_quaternion_get_type(),
}
}
impl Quaternion {
#[doc(alias = "graphene_quaternion_add")]
#[must_use]
pub fn add(&self, b: &Quaternion) -> Quaternion {
unsafe {
let mut res = Quaternion::uninitialized();
ffi::graphene_quaternion_add(
self.to_glib_none().0,
b.to_glib_none().0,
res.to_glib_none_mut().0,
);
res
}
}
#[doc(alias = "graphene_quaternion_dot")]
pub fn dot(&self, b: &Quaternion) -> f32 {
unsafe { ffi::graphene_quaternion_dot(self.to_glib_none().0, b.to_glib_none().0) }
}
#[doc(alias = "graphene_quaternion_equal")]
fn equal(&self, b: &Quaternion) -> bool {
unsafe { ffi::graphene_quaternion_equal(self.to_glib_none().0, b.to_glib_none().0) }
}
#[doc(alias = "graphene_quaternion_invert")]
#[must_use]
pub fn invert(&self) -> Quaternion {
unsafe {
let mut res = Quaternion::uninitialized();
ffi::graphene_quaternion_invert(self.to_glib_none().0, res.to_glib_none_mut().0);
res
}
}
#[doc(alias = "graphene_quaternion_multiply")]
#[must_use]
pub fn multiply(&self, b: &Quaternion) -> Quaternion {
unsafe {
let mut res = Quaternion::uninitialized();
ffi::graphene_quaternion_multiply(
self.to_glib_none().0,
b.to_glib_none().0,
res.to_glib_none_mut().0,
);
res
}
}
#[doc(alias = "graphene_quaternion_normalize")]
#[must_use]
pub fn normalize(&self) -> Quaternion {
unsafe {
let mut res = Quaternion::uninitialized();
ffi::graphene_quaternion_normalize(self.to_glib_none().0, res.to_glib_none_mut().0);
res
}
}
#[doc(alias = "graphene_quaternion_scale")]
#[must_use]
pub fn scale(&self, factor: f32) -> Quaternion {
unsafe {
let mut res = Quaternion::uninitialized();
ffi::graphene_quaternion_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0);
res
}
}
#[doc(alias = "graphene_quaternion_slerp")]
#[must_use]
pub fn slerp(&self, b: &Quaternion, factor: f32) -> Quaternion {
unsafe {
let mut res = Quaternion::uninitialized();
ffi::graphene_quaternion_slerp(
self.to_glib_none().0,
b.to_glib_none().0,
factor,
res.to_glib_none_mut().0,
);
res
}
}
#[doc(alias = "graphene_quaternion_to_angle_vec3")]
pub fn to_angle_vec3(&self) -> (f32, Vec3) {
unsafe {
let mut angle = mem::MaybeUninit::uninit();
let mut axis = Vec3::uninitialized();
ffi::graphene_quaternion_to_angle_vec3(
self.to_glib_none().0,
angle.as_mut_ptr(),
axis.to_glib_none_mut().0,
);
(angle.assume_init(), axis)
}
}
#[doc(alias = "graphene_quaternion_to_angles")]
pub fn to_angles(&self) -> (f32, f32, f32) {
unsafe {
let mut deg_x = mem::MaybeUninit::uninit();
let mut deg_y = mem::MaybeUninit::uninit();
let mut deg_z = mem::MaybeUninit::uninit();
ffi::graphene_quaternion_to_angles(
self.to_glib_none().0,
deg_x.as_mut_ptr(),
deg_y.as_mut_ptr(),
deg_z.as_mut_ptr(),
);
(
deg_x.assume_init(),
deg_y.assume_init(),
deg_z.assume_init(),
)
}
}
#[doc(alias = "graphene_quaternion_to_matrix")]
pub fn to_matrix(&self) -> Matrix {
unsafe {
let mut m = Matrix::uninitialized();
ffi::graphene_quaternion_to_matrix(self.to_glib_none().0, m.to_glib_none_mut().0);
m
}
}
#[doc(alias = "graphene_quaternion_to_radians")]
pub fn to_radians(&self) -> (f32, f32, f32) {
unsafe {
let mut rad_x = mem::MaybeUninit::uninit();
let mut rad_y = mem::MaybeUninit::uninit();
let mut rad_z = mem::MaybeUninit::uninit();
ffi::graphene_quaternion_to_radians(
self.to_glib_none().0,
rad_x.as_mut_ptr(),
rad_y.as_mut_ptr(),
rad_z.as_mut_ptr(),
);
(
rad_x.assume_init(),
rad_y.assume_init(),
rad_z.assume_init(),
)
}
}
#[doc(alias = "graphene_quaternion_to_vec4")]
pub fn to_vec4(&self) -> Vec4 {
unsafe {
let mut res = Vec4::uninitialized();
ffi::graphene_quaternion_to_vec4(self.to_glib_none().0, res.to_glib_none_mut().0);
res
}
}
}
impl PartialEq for Quaternion {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for Quaternion {}