cogl/auto/euler.rs
1use crate::Matrix;
2// use crate::Quaternion;
3
4use glib::translate::*;
5use std::boxed::Box as Box_;
6
7glib_wrapper! {
8 #[derive(Debug, PartialOrd, Ord)] // Hash
9 pub struct Euler(Boxed<ffi::CoglEuler>);
10
11 match fn {
12 copy => |ptr| ffi::cogl_euler_copy(mut_override(ptr)),
13 free => |ptr| ffi::cogl_euler_free(ptr),
14 get_type => || ffi::cogl_euler_get_gtype(),
15 }
16}
17
18impl Euler {
19 /// Initializes `self` to represent a rotation of `x_angle` degrees
20 /// around the x axis, then `y_angle` degrees around the y_axis and
21 /// `z_angle` degrees around the z axis.
22 ///
23 /// ## `heading`
24 /// Angle to rotate around an object's y axis
25 /// ## `pitch`
26 /// Angle to rotate around an object's x axis
27 /// ## `roll`
28 /// Angle to rotate around an object's z axis
29 pub fn init(&mut self, heading: f32, pitch: f32, roll: f32) {
30 unsafe {
31 ffi::cogl_euler_init(self.to_glib_none_mut().0, heading, pitch, roll);
32 }
33 }
34
35 /// Extracts a euler rotation from the given `matrix` and
36 /// initializses `self` with the component x, y and z rotation angles.
37 ///
38 /// ## `matrix`
39 /// A `Matrix` containing a rotation, but no scaling,
40 /// mirroring or skewing.
41 pub fn init_from_matrix(&mut self, matrix: &Matrix) {
42 unsafe {
43 ffi::cogl_euler_init_from_matrix(self.to_glib_none_mut().0, matrix.to_glib_none().0);
44 }
45 }
46
47 // /// Initializes a `self` rotation with the equivalent rotation
48 // /// represented by the given `quaternion`.
49 // ///
50 // /// ## `quaternion`
51 // /// A `Euler` with the rotation to initialize with
52 // pub fn init_from_quaternion(&mut self, quaternion: &Quaternion) {
53 // unsafe {
54 // ffi::cogl_euler_init_from_quaternion(
55 // self.to_glib_none_mut().0,
56 // quaternion.to_glib_none().0,
57 // );
58 // }
59 // }
60
61 fn equal(v1: &Self, v2: &Self) -> bool {
62 let a = Box_::into_raw(Box::new(v1)) as *mut _;
63 let b = Box_::into_raw(Box::new(v2)) as *mut _;
64 unsafe { ffi::cogl_euler_equal(a, b) == crate::TRUE }
65 }
66}
67
68impl PartialEq for Euler {
69 #[inline]
70 fn eq(&self, other: &Self) -> bool {
71 Euler::equal(self, other)
72 }
73}
74
75impl Eq for Euler {}