graphene/auto/
point3_d.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, Rect, Vec3};
6use glib::translate::*;
7
8glib::wrapper! {
9    pub struct Point3D(BoxedInline<ffi::graphene_point3d_t>);
10
11    match fn {
12        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_point3d_get_type(), ptr as *mut _) as *mut ffi::graphene_point3d_t,
13        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_point3d_get_type(), ptr as *mut _),
14        type_ => || ffi::graphene_point3d_get_type(),
15    }
16}
17
18impl Point3D {
19    #[doc(alias = "graphene_point3d_cross")]
20    #[must_use]
21    pub fn cross(&self, b: &Point3D) -> Point3D {
22        unsafe {
23            let mut res = Point3D::uninitialized();
24            ffi::graphene_point3d_cross(
25                self.to_glib_none().0,
26                b.to_glib_none().0,
27                res.to_glib_none_mut().0,
28            );
29            res
30        }
31    }
32
33    #[doc(alias = "graphene_point3d_distance")]
34    pub fn distance(&self, b: &Point3D) -> (f32, Vec3) {
35        unsafe {
36            let mut delta = Vec3::uninitialized();
37            let ret = ffi::graphene_point3d_distance(
38                self.to_glib_none().0,
39                b.to_glib_none().0,
40                delta.to_glib_none_mut().0,
41            );
42            (ret, delta)
43        }
44    }
45
46    #[doc(alias = "graphene_point3d_dot")]
47    pub fn dot(&self, b: &Point3D) -> f32 {
48        unsafe { ffi::graphene_point3d_dot(self.to_glib_none().0, b.to_glib_none().0) }
49    }
50
51    #[doc(alias = "graphene_point3d_equal")]
52    fn equal(&self, b: &Point3D) -> bool {
53        unsafe { ffi::graphene_point3d_equal(self.to_glib_none().0, b.to_glib_none().0) }
54    }
55
56    #[doc(alias = "graphene_point3d_interpolate")]
57    #[must_use]
58    pub fn interpolate(&self, b: &Point3D, factor: f64) -> Point3D {
59        unsafe {
60            let mut res = Point3D::uninitialized();
61            ffi::graphene_point3d_interpolate(
62                self.to_glib_none().0,
63                b.to_glib_none().0,
64                factor,
65                res.to_glib_none_mut().0,
66            );
67            res
68        }
69    }
70
71    #[doc(alias = "graphene_point3d_length")]
72    pub fn length(&self) -> f32 {
73        unsafe { ffi::graphene_point3d_length(self.to_glib_none().0) }
74    }
75
76    #[doc(alias = "graphene_point3d_near")]
77    pub fn near(&self, b: &Point3D, epsilon: f32) -> bool {
78        unsafe { ffi::graphene_point3d_near(self.to_glib_none().0, b.to_glib_none().0, epsilon) }
79    }
80
81    #[doc(alias = "graphene_point3d_normalize")]
82    #[must_use]
83    pub fn normalize(&self) -> Point3D {
84        unsafe {
85            let mut res = Point3D::uninitialized();
86            ffi::graphene_point3d_normalize(self.to_glib_none().0, res.to_glib_none_mut().0);
87            res
88        }
89    }
90
91    #[doc(alias = "graphene_point3d_normalize_viewport")]
92    #[must_use]
93    pub fn normalize_viewport(&self, viewport: &Rect, z_near: f32, z_far: f32) -> Point3D {
94        unsafe {
95            let mut res = Point3D::uninitialized();
96            ffi::graphene_point3d_normalize_viewport(
97                self.to_glib_none().0,
98                viewport.to_glib_none().0,
99                z_near,
100                z_far,
101                res.to_glib_none_mut().0,
102            );
103            res
104        }
105    }
106
107    #[doc(alias = "graphene_point3d_scale")]
108    #[must_use]
109    pub fn scale(&self, factor: f32) -> Point3D {
110        unsafe {
111            let mut res = Point3D::uninitialized();
112            ffi::graphene_point3d_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0);
113            res
114        }
115    }
116
117    #[doc(alias = "graphene_point3d_to_vec3")]
118    pub fn to_vec3(&self) -> Vec3 {
119        unsafe {
120            let mut v = Vec3::uninitialized();
121            ffi::graphene_point3d_to_vec3(self.to_glib_none().0, v.to_glib_none_mut().0);
122            v
123        }
124    }
125
126    #[doc(alias = "graphene_point3d_zero")]
127    pub fn zero() -> Point3D {
128        assert_initialized_main_thread!();
129        unsafe { from_glib_none(ffi::graphene_point3d_zero()) }
130    }
131}
132
133impl PartialEq for Point3D {
134    #[inline]
135    fn eq(&self, other: &Self) -> bool {
136        self.equal(other)
137    }
138}
139
140impl Eq for Point3D {}