1use crate::{ffi, Vec2, Vec4};
6use glib::translate::*;
7
8glib::wrapper! {
9 pub struct Vec3(BoxedInline<ffi::graphene_vec3_t>);
10
11 match fn {
12 copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_vec3_get_type(), ptr as *mut _) as *mut ffi::graphene_vec3_t,
13 free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_vec3_get_type(), ptr as *mut _),
14 type_ => || ffi::graphene_vec3_get_type(),
15 }
16}
17
18impl Vec3 {
19 #[doc(alias = "graphene_vec3_add")]
20 #[must_use]
21 pub fn add(&self, b: &Vec3) -> Vec3 {
22 unsafe {
23 let mut res = Vec3::uninitialized();
24 ffi::graphene_vec3_add(
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_vec3_cross")]
34 #[must_use]
35 pub fn cross(&self, b: &Vec3) -> Vec3 {
36 unsafe {
37 let mut res = Vec3::uninitialized();
38 ffi::graphene_vec3_cross(
39 self.to_glib_none().0,
40 b.to_glib_none().0,
41 res.to_glib_none_mut().0,
42 );
43 res
44 }
45 }
46
47 #[doc(alias = "graphene_vec3_divide")]
48 #[must_use]
49 pub fn divide(&self, b: &Vec3) -> Vec3 {
50 unsafe {
51 let mut res = Vec3::uninitialized();
52 ffi::graphene_vec3_divide(
53 self.to_glib_none().0,
54 b.to_glib_none().0,
55 res.to_glib_none_mut().0,
56 );
57 res
58 }
59 }
60
61 #[doc(alias = "graphene_vec3_dot")]
62 pub fn dot(&self, b: &Vec3) -> f32 {
63 unsafe { ffi::graphene_vec3_dot(self.to_glib_none().0, b.to_glib_none().0) }
64 }
65
66 #[doc(alias = "graphene_vec3_equal")]
67 fn equal(&self, v2: &Vec3) -> bool {
68 unsafe { ffi::graphene_vec3_equal(self.to_glib_none().0, v2.to_glib_none().0) }
69 }
70
71 #[doc(alias = "graphene_vec3_get_x")]
72 #[doc(alias = "get_x")]
73 pub fn x(&self) -> f32 {
74 unsafe { ffi::graphene_vec3_get_x(self.to_glib_none().0) }
75 }
76
77 #[doc(alias = "graphene_vec3_get_xy")]
78 #[doc(alias = "get_xy")]
79 pub fn xy(&self) -> Vec2 {
80 unsafe {
81 let mut res = Vec2::uninitialized();
82 ffi::graphene_vec3_get_xy(self.to_glib_none().0, res.to_glib_none_mut().0);
83 res
84 }
85 }
86
87 #[doc(alias = "graphene_vec3_get_xy0")]
88 #[doc(alias = "get_xy0")]
89 #[must_use]
90 pub fn xy0(&self) -> Vec3 {
91 unsafe {
92 let mut res = Vec3::uninitialized();
93 ffi::graphene_vec3_get_xy0(self.to_glib_none().0, res.to_glib_none_mut().0);
94 res
95 }
96 }
97
98 #[doc(alias = "graphene_vec3_get_xyz0")]
99 #[doc(alias = "get_xyz0")]
100 pub fn xyz0(&self) -> Vec4 {
101 unsafe {
102 let mut res = Vec4::uninitialized();
103 ffi::graphene_vec3_get_xyz0(self.to_glib_none().0, res.to_glib_none_mut().0);
104 res
105 }
106 }
107
108 #[doc(alias = "graphene_vec3_get_xyz1")]
109 #[doc(alias = "get_xyz1")]
110 pub fn xyz1(&self) -> Vec4 {
111 unsafe {
112 let mut res = Vec4::uninitialized();
113 ffi::graphene_vec3_get_xyz1(self.to_glib_none().0, res.to_glib_none_mut().0);
114 res
115 }
116 }
117
118 #[doc(alias = "graphene_vec3_get_xyzw")]
119 #[doc(alias = "get_xyzw")]
120 pub fn xyzw(&self, w: f32) -> Vec4 {
121 unsafe {
122 let mut res = Vec4::uninitialized();
123 ffi::graphene_vec3_get_xyzw(self.to_glib_none().0, w, res.to_glib_none_mut().0);
124 res
125 }
126 }
127
128 #[doc(alias = "graphene_vec3_get_y")]
129 #[doc(alias = "get_y")]
130 pub fn y(&self) -> f32 {
131 unsafe { ffi::graphene_vec3_get_y(self.to_glib_none().0) }
132 }
133
134 #[doc(alias = "graphene_vec3_get_z")]
135 #[doc(alias = "get_z")]
136 pub fn z(&self) -> f32 {
137 unsafe { ffi::graphene_vec3_get_z(self.to_glib_none().0) }
138 }
139
140 #[doc(alias = "graphene_vec3_interpolate")]
141 #[must_use]
142 pub fn interpolate(&self, v2: &Vec3, factor: f64) -> Vec3 {
143 unsafe {
144 let mut res = Vec3::uninitialized();
145 ffi::graphene_vec3_interpolate(
146 self.to_glib_none().0,
147 v2.to_glib_none().0,
148 factor,
149 res.to_glib_none_mut().0,
150 );
151 res
152 }
153 }
154
155 #[doc(alias = "graphene_vec3_length")]
156 pub fn length(&self) -> f32 {
157 unsafe { ffi::graphene_vec3_length(self.to_glib_none().0) }
158 }
159
160 #[doc(alias = "graphene_vec3_max")]
161 #[must_use]
162 pub fn max(&self, b: &Vec3) -> Vec3 {
163 unsafe {
164 let mut res = Vec3::uninitialized();
165 ffi::graphene_vec3_max(
166 self.to_glib_none().0,
167 b.to_glib_none().0,
168 res.to_glib_none_mut().0,
169 );
170 res
171 }
172 }
173
174 #[doc(alias = "graphene_vec3_min")]
175 #[must_use]
176 pub fn min(&self, b: &Vec3) -> Vec3 {
177 unsafe {
178 let mut res = Vec3::uninitialized();
179 ffi::graphene_vec3_min(
180 self.to_glib_none().0,
181 b.to_glib_none().0,
182 res.to_glib_none_mut().0,
183 );
184 res
185 }
186 }
187
188 #[doc(alias = "graphene_vec3_multiply")]
189 #[must_use]
190 pub fn multiply(&self, b: &Vec3) -> Vec3 {
191 unsafe {
192 let mut res = Vec3::uninitialized();
193 ffi::graphene_vec3_multiply(
194 self.to_glib_none().0,
195 b.to_glib_none().0,
196 res.to_glib_none_mut().0,
197 );
198 res
199 }
200 }
201
202 #[doc(alias = "graphene_vec3_near")]
203 pub fn near(&self, v2: &Vec3, epsilon: f32) -> bool {
204 unsafe { ffi::graphene_vec3_near(self.to_glib_none().0, v2.to_glib_none().0, epsilon) }
205 }
206
207 #[doc(alias = "graphene_vec3_negate")]
208 #[must_use]
209 pub fn negate(&self) -> Vec3 {
210 unsafe {
211 let mut res = Vec3::uninitialized();
212 ffi::graphene_vec3_negate(self.to_glib_none().0, res.to_glib_none_mut().0);
213 res
214 }
215 }
216
217 #[doc(alias = "graphene_vec3_normalize")]
218 #[must_use]
219 pub fn normalize(&self) -> Vec3 {
220 unsafe {
221 let mut res = Vec3::uninitialized();
222 ffi::graphene_vec3_normalize(self.to_glib_none().0, res.to_glib_none_mut().0);
223 res
224 }
225 }
226
227 #[doc(alias = "graphene_vec3_scale")]
228 #[must_use]
229 pub fn scale(&self, factor: f32) -> Vec3 {
230 unsafe {
231 let mut res = Vec3::uninitialized();
232 ffi::graphene_vec3_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0);
233 res
234 }
235 }
236
237 #[doc(alias = "graphene_vec3_subtract")]
238 #[must_use]
239 pub fn subtract(&self, b: &Vec3) -> Vec3 {
240 unsafe {
241 let mut res = Vec3::uninitialized();
242 ffi::graphene_vec3_subtract(
243 self.to_glib_none().0,
244 b.to_glib_none().0,
245 res.to_glib_none_mut().0,
246 );
247 res
248 }
249 }
250
251 #[doc(alias = "graphene_vec3_one")]
252 pub fn one() -> Vec3 {
253 assert_initialized_main_thread!();
254 unsafe { from_glib_none(ffi::graphene_vec3_one()) }
255 }
256
257 #[doc(alias = "graphene_vec3_x_axis")]
258 pub fn x_axis() -> Vec3 {
259 assert_initialized_main_thread!();
260 unsafe { from_glib_none(ffi::graphene_vec3_x_axis()) }
261 }
262
263 #[doc(alias = "graphene_vec3_y_axis")]
264 pub fn y_axis() -> Vec3 {
265 assert_initialized_main_thread!();
266 unsafe { from_glib_none(ffi::graphene_vec3_y_axis()) }
267 }
268
269 #[doc(alias = "graphene_vec3_z_axis")]
270 pub fn z_axis() -> Vec3 {
271 assert_initialized_main_thread!();
272 unsafe { from_glib_none(ffi::graphene_vec3_z_axis()) }
273 }
274
275 #[doc(alias = "graphene_vec3_zero")]
276 pub fn zero() -> Vec3 {
277 assert_initialized_main_thread!();
278 unsafe { from_glib_none(ffi::graphene_vec3_zero()) }
279 }
280}
281
282impl PartialEq for Vec3 {
283 #[inline]
284 fn eq(&self, other: &Self) -> bool {
285 self.equal(other)
286 }
287}
288
289impl Eq for Vec3 {}