graphene/auto/euler.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, EulerOrder, Matrix, Quaternion, Vec3};
6use glib::translate::*;
7
8glib::wrapper! {
9 /// Describe a rotation using Euler angles.
10 ///
11 /// The contents of the [`Euler`][crate::Euler] structure are private
12 /// and should never be accessed directly.
13 pub struct Euler(BoxedInline<ffi::graphene_euler_t>);
14
15 match fn {
16 copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_euler_get_type(), ptr as *mut _) as *mut ffi::graphene_euler_t,
17 free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_euler_get_type(), ptr as *mut _),
18 type_ => || ffi::graphene_euler_get_type(),
19 }
20}
21
22impl Euler {
23 #[doc(alias = "graphene_euler_equal")]
24 fn equal(&self, b: &Euler) -> bool {
25 unsafe { ffi::graphene_euler_equal(self.to_glib_none().0, b.to_glib_none().0) }
26 }
27
28 /// Retrieves the first component of the Euler angle vector,
29 /// depending on the order of rotation.
30 ///
31 /// See also: [`x()`][Self::x()]
32 ///
33 /// # Returns
34 ///
35 /// the first component of the Euler angle vector, in radians
36 #[doc(alias = "graphene_euler_get_alpha")]
37 #[doc(alias = "get_alpha")]
38 pub fn alpha(&self) -> f32 {
39 unsafe { ffi::graphene_euler_get_alpha(self.to_glib_none().0) }
40 }
41
42 /// Retrieves the second component of the Euler angle vector,
43 /// depending on the order of rotation.
44 ///
45 /// See also: [`y()`][Self::y()]
46 ///
47 /// # Returns
48 ///
49 /// the second component of the Euler angle vector, in radians
50 #[doc(alias = "graphene_euler_get_beta")]
51 #[doc(alias = "get_beta")]
52 pub fn beta(&self) -> f32 {
53 unsafe { ffi::graphene_euler_get_beta(self.to_glib_none().0) }
54 }
55
56 /// Retrieves the third component of the Euler angle vector,
57 /// depending on the order of rotation.
58 ///
59 /// See also: [`z()`][Self::z()]
60 ///
61 /// # Returns
62 ///
63 /// the third component of the Euler angle vector, in radians
64 #[doc(alias = "graphene_euler_get_gamma")]
65 #[doc(alias = "get_gamma")]
66 pub fn gamma(&self) -> f32 {
67 unsafe { ffi::graphene_euler_get_gamma(self.to_glib_none().0) }
68 }
69
70 /// Retrieves the order used to apply the rotations described in the
71 /// [`Euler`][crate::Euler] structure, when converting to and from other
72 /// structures, like [`Quaternion`][crate::Quaternion] and [`Matrix`][crate::Matrix].
73 ///
74 /// This function does not return the [`EulerOrder::Default`][crate::EulerOrder::Default]
75 /// enumeration value; it will return the effective order of rotation
76 /// instead.
77 ///
78 /// # Returns
79 ///
80 /// the order used to apply the rotations
81 #[doc(alias = "graphene_euler_get_order")]
82 #[doc(alias = "get_order")]
83 pub fn order(&self) -> EulerOrder {
84 unsafe { from_glib(ffi::graphene_euler_get_order(self.to_glib_none().0)) }
85 }
86
87 /// Retrieves the rotation angle on the X axis, in degrees.
88 ///
89 /// # Returns
90 ///
91 /// the rotation angle
92 #[doc(alias = "graphene_euler_get_x")]
93 #[doc(alias = "get_x")]
94 pub fn x(&self) -> f32 {
95 unsafe { ffi::graphene_euler_get_x(self.to_glib_none().0) }
96 }
97
98 /// Retrieves the rotation angle on the Y axis, in degrees.
99 ///
100 /// # Returns
101 ///
102 /// the rotation angle
103 #[doc(alias = "graphene_euler_get_y")]
104 #[doc(alias = "get_y")]
105 pub fn y(&self) -> f32 {
106 unsafe { ffi::graphene_euler_get_y(self.to_glib_none().0) }
107 }
108
109 /// Retrieves the rotation angle on the Z axis, in degrees.
110 ///
111 /// # Returns
112 ///
113 /// the rotation angle
114 #[doc(alias = "graphene_euler_get_z")]
115 #[doc(alias = "get_z")]
116 pub fn z(&self) -> f32 {
117 unsafe { ffi::graphene_euler_get_z(self.to_glib_none().0) }
118 }
119
120 /// Reorders a [`Euler`][crate::Euler] using `order`.
121 ///
122 /// This function is equivalent to creating a [`Quaternion`][crate::Quaternion] from the
123 /// given [`Euler`][crate::Euler], and then converting the quaternion into another
124 /// [`Euler`][crate::Euler].
125 /// ## `order`
126 /// the new order
127 ///
128 /// # Returns
129 ///
130 ///
131 /// ## `res`
132 /// return location for the reordered
133 /// [`Euler`][crate::Euler]
134 #[doc(alias = "graphene_euler_reorder")]
135 #[must_use]
136 pub fn reorder(&self, order: EulerOrder) -> Euler {
137 unsafe {
138 let mut res = Euler::uninitialized();
139 ffi::graphene_euler_reorder(
140 self.to_glib_none().0,
141 order.into_glib(),
142 res.to_glib_none_mut().0,
143 );
144 res
145 }
146 }
147
148 /// Converts a [`Euler`][crate::Euler] into a transformation matrix expressing
149 /// the extrinsic composition of rotations described by the Euler angles.
150 ///
151 /// The rotations are applied over the reference frame axes in the order
152 /// associated with the [`Euler`][crate::Euler]; for instance, if the order
153 /// used to initialize `self` is [`EulerOrder::Xyz`][crate::EulerOrder::Xyz]:
154 ///
155 /// * the first rotation moves the body around the X axis with
156 /// an angle φ
157 /// * the second rotation moves the body around the Y axis with
158 /// an angle of ϑ
159 /// * the third rotation moves the body around the Z axis with
160 /// an angle of ψ
161 ///
162 /// The rotation sign convention is right-handed, to preserve compatibility
163 /// between Euler-based, quaternion-based, and angle-axis-based rotations.
164 ///
165 /// # Returns
166 ///
167 ///
168 /// ## `res`
169 /// return location for a [`Matrix`][crate::Matrix]
170 #[doc(alias = "graphene_euler_to_matrix")]
171 pub fn to_matrix(&self) -> Matrix {
172 unsafe {
173 let mut res = Matrix::uninitialized();
174 ffi::graphene_euler_to_matrix(self.to_glib_none().0, res.to_glib_none_mut().0);
175 res
176 }
177 }
178
179 /// Converts a [`Euler`][crate::Euler] into a [`Quaternion`][crate::Quaternion].
180 ///
181 /// # Returns
182 ///
183 ///
184 /// ## `res`
185 /// return location for a [`Quaternion`][crate::Quaternion]
186 #[doc(alias = "graphene_euler_to_quaternion")]
187 pub fn to_quaternion(&self) -> Quaternion {
188 unsafe {
189 let mut res = Quaternion::uninitialized();
190 ffi::graphene_euler_to_quaternion(self.to_glib_none().0, res.to_glib_none_mut().0);
191 res
192 }
193 }
194
195 /// Retrieves the angles of a [`Euler`][crate::Euler] and initializes a
196 /// [`Vec3`][crate::Vec3] with them.
197 ///
198 /// # Returns
199 ///
200 ///
201 /// ## `res`
202 /// return location for a [`Vec3`][crate::Vec3]
203 #[doc(alias = "graphene_euler_to_vec3")]
204 pub fn to_vec3(&self) -> Vec3 {
205 unsafe {
206 let mut res = Vec3::uninitialized();
207 ffi::graphene_euler_to_vec3(self.to_glib_none().0, res.to_glib_none_mut().0);
208 res
209 }
210 }
211}
212
213impl PartialEq for Euler {
214 #[inline]
215 fn eq(&self, other: &Self) -> bool {
216 self.equal(other)
217 }
218}
219
220impl Eq for Euler {}