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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::EulerOrder; use crate::Matrix; use crate::Quaternion; use crate::Vec3; use glib::translate::*; glib::wrapper! { /// Describe a rotation using Euler angles. /// /// The contents of the [`Euler`][crate::Euler] structure are private /// and should never be accessed directly. #[derive(Debug, PartialOrd, Ord, Hash)] pub struct Euler(Boxed<ffi::graphene_euler_t>); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_euler_get_type(), ptr as *mut _) as *mut ffi::graphene_euler_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_euler_get_type(), ptr as *mut _), init => |_ptr| (), clear => |_ptr| (), type_ => || ffi::graphene_euler_get_type(), } } impl Euler { /// Checks if two [`Euler`][crate::Euler] are equal. /// ## `b` /// a [`Euler`][crate::Euler] /// /// # Returns /// /// `true` if the two [`Euler`][crate::Euler] are equal #[doc(alias = "graphene_euler_equal")] fn equal(&self, b: &Euler) -> bool { unsafe { from_glib(ffi::graphene_euler_equal( self.to_glib_none().0, b.to_glib_none().0, )) } } /// Retrieves the first component of the Euler angle vector, /// depending on the order of rotation. /// /// See also: [`x()`][Self::x()] /// /// # Returns /// /// the first component of the Euler angle vector, in radians #[doc(alias = "graphene_euler_get_alpha")] #[doc(alias = "get_alpha")] pub fn alpha(&self) -> f32 { unsafe { ffi::graphene_euler_get_alpha(self.to_glib_none().0) } } /// Retrieves the second component of the Euler angle vector, /// depending on the order of rotation. /// /// See also: [`y()`][Self::y()] /// /// # Returns /// /// the second component of the Euler angle vector, in radians #[doc(alias = "graphene_euler_get_beta")] #[doc(alias = "get_beta")] pub fn beta(&self) -> f32 { unsafe { ffi::graphene_euler_get_beta(self.to_glib_none().0) } } /// Retrieves the third component of the Euler angle vector, /// depending on the order of rotation. /// /// See also: [`z()`][Self::z()] /// /// # Returns /// /// the third component of the Euler angle vector, in radians #[doc(alias = "graphene_euler_get_gamma")] #[doc(alias = "get_gamma")] pub fn gamma(&self) -> f32 { unsafe { ffi::graphene_euler_get_gamma(self.to_glib_none().0) } } /// Retrieves the order used to apply the rotations described in the /// [`Euler`][crate::Euler] structure, when converting to and from other /// structures, like [`Quaternion`][crate::Quaternion] and [`Matrix`][crate::Matrix]. /// /// This function does not return the [`EulerOrder::Default`][crate::EulerOrder::Default] /// enumeration value; it will return the effective order of rotation /// instead. /// /// # Returns /// /// the order used to apply the rotations #[doc(alias = "graphene_euler_get_order")] #[doc(alias = "get_order")] pub fn order(&self) -> EulerOrder { unsafe { from_glib(ffi::graphene_euler_get_order(self.to_glib_none().0)) } } /// Retrieves the rotation angle on the X axis, in degrees. /// /// # Returns /// /// the rotation angle #[doc(alias = "graphene_euler_get_x")] #[doc(alias = "get_x")] pub fn x(&self) -> f32 { unsafe { ffi::graphene_euler_get_x(self.to_glib_none().0) } } /// Retrieves the rotation angle on the Y axis, in degrees. /// /// # Returns /// /// the rotation angle #[doc(alias = "graphene_euler_get_y")] #[doc(alias = "get_y")] pub fn y(&self) -> f32 { unsafe { ffi::graphene_euler_get_y(self.to_glib_none().0) } } /// Retrieves the rotation angle on the Z axis, in degrees. /// /// # Returns /// /// the rotation angle #[doc(alias = "graphene_euler_get_z")] #[doc(alias = "get_z")] pub fn z(&self) -> f32 { unsafe { ffi::graphene_euler_get_z(self.to_glib_none().0) } } /// Initializes a [`Euler`][crate::Euler] using the given angles. /// /// The order of the rotations is [`EulerOrder::Default`][crate::EulerOrder::Default]. /// ## `x` /// rotation angle on the X axis, in degrees /// ## `y` /// rotation angle on the Y axis, in degrees /// ## `z` /// rotation angle on the Z axis, in degrees /// /// # Returns /// /// the initialized [`Euler`][crate::Euler] #[doc(alias = "graphene_euler_init")] pub fn init(&mut self, x: f32, y: f32, z: f32) { unsafe { ffi::graphene_euler_init(self.to_glib_none_mut().0, x, y, z); } } /// Initializes a [`Euler`][crate::Euler] using the angles and order of /// another [`Euler`][crate::Euler]. /// /// If the [`Euler`][crate::Euler] `src` is [`None`], this function is equivalent /// to calling [`init()`][Self::init()] with all angles set to 0. /// ## `src` /// a [`Euler`][crate::Euler] /// /// # Returns /// /// the initialized [`Euler`][crate::Euler] #[doc(alias = "graphene_euler_init_from_euler")] pub fn init_from_euler(&mut self, src: Option<&Euler>) { unsafe { ffi::graphene_euler_init_from_euler(self.to_glib_none_mut().0, src.to_glib_none().0); } } /// Initializes a [`Euler`][crate::Euler] using the given rotation matrix. /// /// If the [`Matrix`][crate::Matrix] `m` is [`None`], the [`Euler`][crate::Euler] will /// be initialized with all angles set to 0. /// ## `m` /// a rotation matrix /// ## `order` /// the order used to apply the rotations /// /// # Returns /// /// the initialized [`Euler`][crate::Euler] #[doc(alias = "graphene_euler_init_from_matrix")] pub fn init_from_matrix(&mut self, m: Option<&Matrix>, order: EulerOrder) { unsafe { ffi::graphene_euler_init_from_matrix( self.to_glib_none_mut().0, m.to_glib_none().0, order.into_glib(), ); } } /// Initializes a [`Euler`][crate::Euler] using the given normalized quaternion. /// /// If the [`Quaternion`][crate::Quaternion] `q` is [`None`], the [`Euler`][crate::Euler] will /// be initialized with all angles set to 0. /// ## `q` /// a normalized [`Quaternion`][crate::Quaternion] /// ## `order` /// the order used to apply the rotations /// /// # Returns /// /// the initialized [`Euler`][crate::Euler] #[doc(alias = "graphene_euler_init_from_quaternion")] pub fn init_from_quaternion(&mut self, q: Option<&Quaternion>, order: EulerOrder) { unsafe { ffi::graphene_euler_init_from_quaternion( self.to_glib_none_mut().0, q.to_glib_none().0, order.into_glib(), ); } } /// Initializes a [`Euler`][crate::Euler] using the given angles /// and order of rotation. /// ## `x` /// rotation angle on the X axis, in radians /// ## `y` /// rotation angle on the Y axis, in radians /// ## `z` /// rotation angle on the Z axis, in radians /// ## `order` /// order of rotations /// /// # Returns /// /// the initialized [`Euler`][crate::Euler] #[doc(alias = "graphene_euler_init_from_radians")] pub fn init_from_radians( &mut self, x: f32, y: f32, z: f32, order: EulerOrder, ) -> Option<Euler> { unsafe { from_glib_none(ffi::graphene_euler_init_from_radians( self.to_glib_none_mut().0, x, y, z, order.into_glib(), )) } } /// Initializes a [`Euler`][crate::Euler] using the angles contained in a /// [`Vec3`][crate::Vec3]. /// /// If the [`Vec3`][crate::Vec3] `v` is [`None`], the [`Euler`][crate::Euler] will be /// initialized with all angles set to 0. /// ## `v` /// a [`Vec3`][crate::Vec3] containing the rotation /// angles in degrees /// ## `order` /// the order used to apply the rotations /// /// # Returns /// /// the initialized [`Euler`][crate::Euler] #[doc(alias = "graphene_euler_init_from_vec3")] pub fn init_from_vec3(&mut self, v: Option<&Vec3>, order: EulerOrder) { unsafe { ffi::graphene_euler_init_from_vec3( self.to_glib_none_mut().0, v.to_glib_none().0, order.into_glib(), ); } } /// Initializes a [`Euler`][crate::Euler] with the given angles and `order`. /// ## `x` /// rotation angle on the X axis, in degrees /// ## `y` /// rotation angle on the Y axis, in degrees /// ## `z` /// rotation angle on the Z axis, in degrees /// ## `order` /// the order used to apply the rotations /// /// # Returns /// /// the initialized [`Euler`][crate::Euler] #[doc(alias = "graphene_euler_init_with_order")] pub fn init_with_order(&mut self, x: f32, y: f32, z: f32, order: EulerOrder) { unsafe { ffi::graphene_euler_init_with_order( self.to_glib_none_mut().0, x, y, z, order.into_glib(), ); } } /// Reorders a [`Euler`][crate::Euler] using `order`. /// /// This function is equivalent to creating a [`Quaternion`][crate::Quaternion] from the /// given [`Euler`][crate::Euler], and then converting the quaternion into another /// [`Euler`][crate::Euler]. /// ## `order` /// the new order /// /// # Returns /// /// /// ## `res` /// return location for the reordered /// [`Euler`][crate::Euler] #[doc(alias = "graphene_euler_reorder")] pub fn reorder(&self, order: EulerOrder) -> Euler { unsafe { let mut res = Euler::uninitialized(); ffi::graphene_euler_reorder( self.to_glib_none().0, order.into_glib(), res.to_glib_none_mut().0, ); res } } /// Converts a [`Euler`][crate::Euler] into a transformation matrix expressing /// the extrinsic composition of rotations described by the Euler angles. /// /// The rotations are applied over the reference frame axes in the order /// associated with the [`Euler`][crate::Euler]; for instance, if the order /// used to initialize `self` is [`EulerOrder::Xyz`][crate::EulerOrder::Xyz]: /// /// * the first rotation moves the body around the X axis with /// an angle φ /// * the second rotation moves the body around the Y axis with /// an angle of ϑ /// * the third rotation moves the body around the Z axis with /// an angle of ψ /// /// The rotation sign convention is right-handed, to preserve compatibility /// between Euler-based, quaternion-based, and angle-axis-based rotations. /// /// # Returns /// /// /// ## `res` /// return location for a [`Matrix`][crate::Matrix] #[doc(alias = "graphene_euler_to_matrix")] pub fn to_matrix(&self) -> Matrix { unsafe { let mut res = Matrix::uninitialized(); ffi::graphene_euler_to_matrix(self.to_glib_none().0, res.to_glib_none_mut().0); res } } /// Converts a [`Euler`][crate::Euler] into a [`Quaternion`][crate::Quaternion]. /// /// # Returns /// /// /// ## `res` /// return location for a [`Quaternion`][crate::Quaternion] #[doc(alias = "graphene_euler_to_quaternion")] pub fn to_quaternion(&self) -> Quaternion { unsafe { let mut res = Quaternion::uninitialized(); ffi::graphene_euler_to_quaternion(self.to_glib_none().0, res.to_glib_none_mut().0); res } } /// Retrieves the angles of a [`Euler`][crate::Euler] and initializes a /// [`Vec3`][crate::Vec3] with them. /// /// # Returns /// /// /// ## `res` /// return location for a [`Vec3`][crate::Vec3] #[doc(alias = "graphene_euler_to_vec3")] pub fn to_vec3(&self) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_euler_to_vec3(self.to_glib_none().0, res.to_glib_none_mut().0); res } } } impl PartialEq for Euler { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Euler {}