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::{EulerOrder, Matrix, Quaternion, Vec3, ffi};
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 ///
149 ///
150 /// The rotation sign convention is right-handed, to preserve compatibility
151 /// between Euler-based, quaternion-based, and angle-axis-based rotations.
152 ///
153 /// # Returns
154 ///
155 ///
156 /// ## `res`
157 /// return location for a [`Matrix`][crate::Matrix]
158 #[doc(alias = "graphene_euler_to_matrix")]
159 pub fn to_matrix(&self) -> Matrix {
160 unsafe {
161 let mut res = Matrix::uninitialized();
162 ffi::graphene_euler_to_matrix(self.to_glib_none().0, res.to_glib_none_mut().0);
163 res
164 }
165 }
166
167 /// Converts a [`Euler`][crate::Euler] into a [`Quaternion`][crate::Quaternion].
168 ///
169 /// # Returns
170 ///
171 ///
172 /// ## `res`
173 /// return location for a [`Quaternion`][crate::Quaternion]
174 #[doc(alias = "graphene_euler_to_quaternion")]
175 pub fn to_quaternion(&self) -> Quaternion {
176 unsafe {
177 let mut res = Quaternion::uninitialized();
178 ffi::graphene_euler_to_quaternion(self.to_glib_none().0, res.to_glib_none_mut().0);
179 res
180 }
181 }
182
183 /// Retrieves the angles of a [`Euler`][crate::Euler] and initializes a
184 /// [`Vec3`][crate::Vec3] with them.
185 ///
186 /// # Returns
187 ///
188 ///
189 /// ## `res`
190 /// return location for a [`Vec3`][crate::Vec3]
191 #[doc(alias = "graphene_euler_to_vec3")]
192 pub fn to_vec3(&self) -> Vec3 {
193 unsafe {
194 let mut res = Vec3::uninitialized();
195 ffi::graphene_euler_to_vec3(self.to_glib_none().0, res.to_glib_none_mut().0);
196 res
197 }
198 }
199}
200
201impl PartialEq for Euler {
202 #[inline]
203 fn eq(&self, other: &Self) -> bool {
204 self.equal(other)
205 }
206}
207
208impl Eq for Euler {}