pybind11Utils.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: pybind11Utils.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: pybind11 utility functions for CubbyFlow Python API.
6 > Created Time: 2018/01/19
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_PYTHON_PYBIND11_UTILS_H
10 #define CUBBYFLOW_PYTHON_PYBIND11_UTILS_H
11 
12 #include <Core/Math/Quaternion.h>
13 #include <Core/Point/Point2.h>
14 #include <Core/Point/Point3.h>
15 #include <Core/Size/Size2.h>
16 #include <Core/Size/Size3.h>
17 #include <Core/Vector/Vector2.h>
18 #include <Core/Vector/Vector3.h>
19 #include <Core/Vector/Vector4.h>
20 
21 #include <pybind11/pybind11.h>
22 #include <pybind11/stl.h>
23 
24 namespace CubbyFlow
25 {
26  inline Size2 TupleToSize2(pybind11::tuple tuple)
27  {
28  Size2 ret;
29 
30  if (tuple.size() == 2)
31  {
32  for (size_t i = 0; i < 2; ++i)
33  {
34  ret[i] = tuple[i].cast<size_t>();
35  }
36  }
37  else
38  {
39  throw std::invalid_argument("Invalid size.");
40  }
41 
42  return ret;
43  }
44 
45  inline Size2 TupleToSize2(pybind11::list list)
46  {
47  Size2 ret;
48 
49  if (list.size() == 2)
50  {
51  for (size_t i = 0; i < 2; ++i)
52  {
53  ret[i] = list[i].cast<size_t>();
54  }
55  }
56  else
57  {
58  throw std::invalid_argument("Invalid size.");
59  }
60 
61  return ret;
62  }
63 
64  inline Size3 TupleToSize3(pybind11::tuple tuple)
65  {
66  Size3 ret;
67 
68  if (tuple.size() == 3)
69  {
70  for (size_t i = 0; i < 3; ++i)
71  {
72  ret[i] = tuple[i].cast<size_t>();
73  }
74  }
75  else
76  {
77  throw std::invalid_argument("Invalid size.");
78  }
79 
80  return ret;
81  }
82 
83  inline Size3 TupleToSize3(pybind11::list list)
84  {
85  Size3 ret;
86 
87  if (list.size() == 3)
88  {
89  for (size_t i = 0; i < 3; ++i)
90  {
91  ret[i] = list[i].cast<size_t>();
92  }
93  }
94  else
95  {
96  throw std::invalid_argument("Invalid size.");
97  }
98 
99  return ret;
100  }
101 
102  inline Point2UI TupleToPoint2UI(pybind11::tuple tuple)
103  {
104  Point2UI ret;
105 
106  if (tuple.size() == 2)
107  {
108  for (size_t i = 0; i < 2; ++i)
109  {
110  ret[i] = tuple[i].cast<size_t>();
111  }
112  }
113  else
114  {
115  throw std::invalid_argument("Invalid size.");
116  }
117 
118  return ret;
119  }
120 
121  inline Point2UI TupleToPoint2UI(pybind11::list list)
122  {
123  Point2UI ret;
124 
125  if (list.size() == 2)
126  {
127  for (size_t i = 0; i < 2; ++i)
128  {
129  ret[i] = list[i].cast<size_t>();
130  }
131  }
132  else
133  {
134  throw std::invalid_argument("Invalid size.");
135  }
136 
137  return ret;
138  }
139 
140  inline Point3UI TupleToPoint3UI(pybind11::tuple tuple)
141  {
142  Point3UI ret;
143 
144  if (tuple.size() == 3)
145  {
146  for (size_t i = 0; i < 3; ++i)
147  {
148  ret[i] = tuple[i].cast<size_t>();
149  }
150  }
151  else
152  {
153  throw std::invalid_argument("Invalid size.");
154  }
155 
156  return ret;
157  }
158 
159  inline Point3UI TupleToPoint3UI(pybind11::list list)
160  {
161  Point3UI ret;
162 
163  if (list.size() == 3)
164  {
165  for (size_t i = 0; i < 3; ++i)
166  {
167  ret[i] = list[i].cast<size_t>();
168  }
169  }
170  else
171  {
172  throw std::invalid_argument("Invalid size.");
173  }
174 
175  return {};
176  }
177 
178  inline pybind11::tuple Size2ToTuple(const Size2& size)
179  {
180  return pybind11::make_tuple(size.x, size.y);
181  }
182 
183  inline pybind11::tuple Size3ToTuple(const Size3& size)
184  {
185  return pybind11::make_tuple(size.x, size.y, size.z);
186  }
187 
188  template <typename T, size_t N>
189  inline Vector<T, N> TupleToVector(pybind11::tuple tuple)
190  {
191  Vector<T, N> ret;
192 
193  if (tuple.size() == N)
194  {
195  for (size_t i = 0; i < N; ++i)
196  {
197  ret[i] = tuple[i].cast<T>();
198  }
199  }
200  else
201  {
202  throw std::invalid_argument("Invalid size.");
203  }
204 
205  return ret;
206  }
207 
208  template <typename T, size_t N>
209  inline Vector<T, N> TupleToVector(pybind11::list list)
210  {
211  Vector<T, N> ret;
212 
213  if (list.size() == N)
214  {
215  for (size_t i = 0; i < N; ++i)
216  {
217  ret[i] = list[i].cast<T>();
218  }
219  }
220  else
221  {
222  throw std::invalid_argument("Invalid size.");
223  }
224 
225  return ret;
226  }
227 
228  template <typename T>
229  inline Quaternion<T> TupleToQuaternion(pybind11::tuple tuple)
230  {
231  Quaternion<T> ret;
232 
233  for (size_t i = 0; i < 4; ++i)
234  {
235  ret[i] = tuple[i].cast<T>();
236  }
237 
238  return ret;
239  }
240 
241  template <typename T>
242  inline Quaternion<T> TupleToQuaternion(pybind11::list list)
243  {
244  Quaternion<T> ret;
245 
246  for (size_t i = 0; i < 4; ++i)
247  {
248  ret[i] = list[i].cast<T>();
249  }
250 
251  return ret;
252  }
253 
254  inline Vector2F TupleToVector2F(pybind11::tuple tuple)
255  {
256  return TupleToVector<float, 2>(tuple);
257  }
258 
259  inline Vector2F TupleToVector2F(pybind11::list list)
260  {
261  return TupleToVector<float, 2>(list);
262  }
263 
264  inline Vector3F TupleToVector3F(pybind11::tuple tuple)
265  {
266  return TupleToVector<float, 3>(tuple);
267  }
268 
269  inline Vector3F TupleToVector3F(pybind11::list list)
270  {
271  return TupleToVector<float, 3>(list);
272  }
273 
274  inline Vector4F TupleToVector4F(pybind11::tuple tuple)
275  {
276  return TupleToVector<float, 4>(tuple);
277  }
278 
279  inline Vector4F TupleToVector4F(pybind11::list list)
280  {
281  return TupleToVector<float, 4>(list);
282  }
283 
284  inline QuaternionF TupleToQuaternionF(pybind11::tuple tuple)
285  {
286  return TupleToQuaternion<float>(tuple);
287  }
288 
289  inline QuaternionF TupleToQuaternionF(pybind11::list list)
290  {
291  return TupleToQuaternion<float>(list);
292  }
293 
294  inline Vector2D TupleToVector2D(pybind11::tuple tuple)
295  {
296  return TupleToVector<double, 2>(tuple);
297  }
298 
299  inline Vector2D TupleToVector2D(pybind11::list list)
300  {
301  return TupleToVector<double, 2>(list);
302  }
303 
304  inline Vector3D TupleToVector3D(pybind11::tuple tuple)
305  {
306  return TupleToVector<double, 3>(tuple);
307  }
308 
309  inline Vector3D TupleToVector3D(pybind11::list list)
310  {
311  return TupleToVector<double, 3>(list);
312  }
313 
314  inline Vector4D TupleToVector4D(pybind11::tuple tuple)
315  {
316  return TupleToVector<double, 4>(tuple);
317  }
318 
319  inline Vector4D TupleToVector4D(pybind11::list list)
320  {
321  return TupleToVector<double, 4>(list);
322  }
323 
324  template <typename T>
325  inline pybind11::tuple Vector2ToTuple(const Vector<T, 2>& vec)
326  {
327  return pybind11::make_tuple(vec.x, vec.y);
328  }
329 
330  template <typename T>
331  inline pybind11::tuple Vector3ToTuple(const Vector<T, 3>& vec)
332  {
333  return pybind11::make_tuple(vec.x, vec.y, vec.z);
334  }
335 
336  template <typename T>
337  inline pybind11::tuple Vector4ToTuple(const Vector<T, 4>& vec)
338  {
339  return pybind11::make_tuple(vec.x, vec.y, vec.z, vec.w);
340  }
341 
342  inline QuaternionD TupleToQuaternionD(pybind11::tuple tuple)
343  {
344  return TupleToQuaternion<double>(tuple);
345  }
346 
347  inline QuaternionD TupleToQuaternionD(pybind11::list list)
348  {
349  return TupleToQuaternion<double>(list);
350  }
351 
352  inline Size2 ObjectToSize2(const pybind11::object& obj)
353  {
354  if (pybind11::isinstance<Size2>(static_cast<pybind11::handle>(obj)))
355  {
356  return obj.cast<Size2>();
357  }
358 
359  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
360  {
361  return TupleToSize2(pybind11::tuple(obj));
362  }
363 
364  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
365  {
366  return TupleToSize2(pybind11::list(obj));
367  }
368 
369  throw std::invalid_argument("Cannot convert to Size2.");
370  }
371 
372  inline Size3 ObjectToSize3(const pybind11::object& obj)
373  {
374  if (pybind11::isinstance<Size3>(static_cast<pybind11::handle>(obj)))
375  {
376  return obj.cast<Size3>();
377  }
378 
379  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
380  {
381  return TupleToSize3(pybind11::tuple(obj));
382  }
383 
384  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
385  {
386  return TupleToSize3(pybind11::list(obj));
387  }
388 
389  throw std::invalid_argument("Cannot convert to Size3.");
390  }
391 
392  inline Point2UI ObjectToPoint2UI(const pybind11::object& obj)
393  {
394  if (pybind11::isinstance<Point2UI>(static_cast<pybind11::handle>(obj)))
395  {
396  return obj.cast<Point2UI>();
397  }
398 
399  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
400  {
401  return TupleToPoint2UI(pybind11::tuple(obj));
402  }
403 
404  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
405  {
406  return TupleToPoint2UI(pybind11::list(obj));
407  }
408 
409  throw std::invalid_argument("Cannot convert to Point2UI.");
410  }
411 
412  inline Point3UI ObjectToPoint3UI(const pybind11::object& obj)
413  {
414  if (pybind11::isinstance<Point3UI>(static_cast<pybind11::handle>(obj)))
415  {
416  return obj.cast<Point3UI>();
417  }
418 
419  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
420  {
421  return TupleToPoint3UI(pybind11::tuple(obj));
422  }
423 
424  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
425  {
426  return TupleToPoint3UI(pybind11::list(obj));
427  }
428 
429  throw std::invalid_argument("Cannot convert to Point3UI.");
430  }
431 
432  inline Vector2F ObjectToVector2F(const pybind11::object& obj)
433  {
434  if (pybind11::isinstance<Vector2F>(static_cast<pybind11::handle>(obj)))
435  {
436  return obj.cast<Vector2F>();
437  }
438 
439  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
440  {
441  return TupleToVector2F(pybind11::tuple(obj));
442  }
443 
444  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
445  {
446  return TupleToVector2F(pybind11::list(obj));
447  }
448 
449  throw std::invalid_argument("Cannot convert to Vector2F.");
450  }
451 
452  inline Vector2D ObjectToVector2D(const pybind11::object& obj)
453  {
454  if (pybind11::isinstance<Vector2D>(static_cast<pybind11::handle>(obj)))
455  {
456  return obj.cast<Vector2D>();
457  }
458 
459  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
460  {
461  return TupleToVector2D(pybind11::tuple(obj));
462  }
463 
464  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
465  {
466  return TupleToVector2D(pybind11::list(obj));
467  }
468 
469  throw std::invalid_argument("Cannot convert to Vector2D.");
470  }
471 
472  inline Vector3F ObjectToVector3F(const pybind11::object& obj)
473  {
474  if (pybind11::isinstance<Vector3F>(static_cast<pybind11::handle>(obj)))
475  {
476  return obj.cast<Vector3F>();
477  }
478 
479  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
480  {
481  return TupleToVector3F(pybind11::tuple(obj));
482  }
483 
484  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
485  {
486  return TupleToVector3F(pybind11::list(obj));
487  }
488 
489  throw std::invalid_argument("Cannot convert to Vector3F.");
490  }
491 
492  inline Vector3D ObjectToVector3D(const pybind11::object& obj)
493  {
494  if (pybind11::isinstance<Vector3D>(static_cast<pybind11::handle>(obj)))
495  {
496  return obj.cast<Vector3D>();
497  }
498 
499  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
500  {
501  return TupleToVector3D(pybind11::tuple(obj));
502  }
503 
504  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
505  {
506  return TupleToVector3D(pybind11::list(obj));
507  }
508 
509  throw std::invalid_argument("Cannot convert to Vector3D.");
510  }
511 
512  inline Vector4F ObjectToVector4F(const pybind11::object& obj)
513  {
514  if (pybind11::isinstance<Vector4F>(static_cast<pybind11::handle>(obj)))
515  {
516  return obj.cast<Vector4F>();
517  }
518 
519  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
520  {
521  return TupleToVector4F(pybind11::tuple(obj));
522  }
523 
524  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
525  {
526  return TupleToVector4F(pybind11::list(obj));
527  }
528 
529  throw std::invalid_argument("Cannot convert to Vector4F.");
530  }
531 
532  inline Vector4D ObjectToVector4D(const pybind11::object& obj)
533  {
534  if (pybind11::isinstance<Vector4D>(static_cast<pybind11::handle>(obj)))
535  {
536  return obj.cast<Vector4D>();
537  }
538 
539  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
540  {
541  return TupleToVector4D(pybind11::tuple(obj));
542  }
543 
544  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
545  {
546  return TupleToVector4D(pybind11::list(obj));
547  }
548 
549  throw std::invalid_argument("Cannot convert to Vector4D.");
550  }
551 
552  inline QuaternionF ObjectToQuaternionF(const pybind11::object& obj)
553  {
554  if (pybind11::isinstance<QuaternionF>(static_cast<pybind11::handle>(obj)))
555  {
556  return obj.cast<QuaternionF>();
557  }
558 
559  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
560  {
561  return TupleToQuaternionF(pybind11::tuple(obj));
562  }
563 
564  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
565  {
566  return TupleToQuaternionF(pybind11::list(obj));
567  }
568 
569  throw std::invalid_argument("Cannot convert to QuaternionF.");
570  }
571 
572  inline QuaternionD ObjectToQuaternionD(const pybind11::object& obj)
573  {
574  if (pybind11::isinstance<QuaternionD>(static_cast<pybind11::handle>(obj)))
575  {
576  return obj.cast<QuaternionD>();
577  }
578 
579  if (pybind11::isinstance<pybind11::tuple>(static_cast<pybind11::handle>(obj)))
580  {
581  return TupleToQuaternionD(pybind11::tuple(obj));
582  }
583 
584  if (pybind11::isinstance<pybind11::list>(static_cast<pybind11::handle>(obj)))
585  {
586  return TupleToQuaternionD(pybind11::list(obj));
587  }
588 
589  throw std::invalid_argument("Cannot convert to QuaternionD.");
590  }
591 
592  inline void ParseGridResizeParams(pybind11::args args, pybind11::kwargs kwargs,
593  Size2& resolution, Vector2D& gridSpacing, Vector2D& gridOrigin)
594  {
595  // See if we have list of parameters
596  if (args.size() <= 3)
597  {
598  if (args.size() > 0)
599  {
600  resolution = ObjectToSize2(pybind11::object(args[0]));
601  }
602  if (args.size() > 1)
603  {
604  gridSpacing = ObjectToVector2D(pybind11::object(args[1]));
605  }
606  if (args.size() > 2)
607  {
608  gridOrigin = ObjectToVector2D(pybind11::object(args[2]));
609  }
610  }
611  else
612  {
613  throw std::invalid_argument("Too many arguments.");
614  }
615 
616  // Parse out keyword args
617  if (kwargs.contains("resolution"))
618  {
619  resolution = ObjectToSize2(pybind11::object(kwargs["resolution"]));
620  }
621  if (kwargs.contains("gridSpacing"))
622  {
623  gridSpacing = ObjectToVector2D(pybind11::object(kwargs["gridSpacing"]));
624  }
625  if (kwargs.contains("gridOrigin"))
626  {
627  gridOrigin = ObjectToVector2D(pybind11::object(kwargs["gridOrigin"]));
628  }
629  if (kwargs.contains("domainSizeX"))
630  {
631  double domainSizeX = kwargs["domainSizeX"].cast<double>();
632  gridSpacing.Set(domainSizeX / static_cast<double>(resolution.x));
633  }
634  }
635 
636  inline void ParseGridResizeParams(pybind11::args args, pybind11::kwargs kwargs,
637  Size3& resolution, Vector3D& gridSpacing, Vector3D& gridOrigin)
638  {
639  // See if we have list of parameters
640  if (args.size() <= 3)
641  {
642  if (args.size() > 0)
643  {
644  resolution = ObjectToSize3(pybind11::object(args[0]));
645  }
646  if (args.size() > 1)
647  {
648  gridSpacing = ObjectToVector3D(pybind11::object(args[1]));
649  }
650  if (args.size() > 2)
651  {
652  gridOrigin = ObjectToVector3D(pybind11::object(args[2]));
653  }
654  }
655  else
656  {
657  throw std::invalid_argument("Too many arguments.");
658  }
659 
660  // Parse out keyword args
661  if (kwargs.contains("resolution"))
662  {
663  resolution = ObjectToSize3(pybind11::object(kwargs["resolution"]));
664  }
665  if (kwargs.contains("gridSpacing"))
666  {
667  gridSpacing = ObjectToVector3D(pybind11::object(kwargs["gridSpacing"]));
668  }
669  if (kwargs.contains("gridOrigin"))
670  {
671  gridOrigin = ObjectToVector3D(pybind11::object(kwargs["gridOrigin"]));
672  }
673  if (kwargs.contains("domainSizeX"))
674  {
675  double domainSizeX = kwargs["domainSizeX"].cast<double>();
676  gridSpacing.Set(domainSizeX / static_cast<double>(resolution.x));
677  }
678  }
679 }
680 
681 #endif
Quaternion< T > TupleToQuaternion(pybind11::tuple tuple)
Definition: pybind11Utils.h:229
3-D vector class.
Definition: Vector3.h:26
Size3 ObjectToSize3(const pybind11::object &obj)
Definition: pybind11Utils.h:372
pybind11::tuple Size3ToTuple(const Size3 &size)
Definition: pybind11Utils.h:183
T x
X (or the first) component of the vector.
Definition: Vector2.h:29
void Set(T s)
Set all x, y, and z components to s.
Definition: Vector3-Impl.h:27
Point2UI TupleToPoint2UI(pybind11::tuple tuple)
Definition: pybind11Utils.h:102
T z
Z (or the third) component of the vector.
Definition: Vector3.h:38
QuaternionD ObjectToQuaternionD(const pybind11::object &obj)
Definition: pybind11Utils.h:572
T x
X (or the first) component of the point.
Definition: Point2.h:28
T y
Y (or the second) component of the vector.
Definition: Vector4.h:35
Vector4D ObjectToVector4D(const pybind11::object &obj)
Definition: pybind11Utils.h:532
pybind11::tuple Vector4ToTuple(const Vector< T, 4 > &vec)
Definition: pybind11Utils.h:337
QuaternionD TupleToQuaternionD(pybind11::tuple tuple)
Definition: pybind11Utils.h:342
Vector4F ObjectToVector4F(const pybind11::object &obj)
Definition: pybind11Utils.h:512
pybind11::tuple Vector3ToTuple(const Vector< T, 3 > &vec)
Definition: pybind11Utils.h:331
Size2 TupleToSize2(pybind11::tuple tuple)
Definition: pybind11Utils.h:26
2-D point class.
Definition: Point2.h:25
Generic statically-sized N-D vector class.
Definition: Vector.h:33
3-D point class.
Definition: Point3.h:26
Size3 TupleToSize3(pybind11::tuple tuple)
Definition: pybind11Utils.h:64
T w
W (or the fourth) component of the vector.
Definition: Vector4.h:41
Vector2D ObjectToVector2D(const pybind11::object &obj)
Definition: pybind11Utils.h:452
Vector3F ObjectToVector3F(const pybind11::object &obj)
Definition: pybind11Utils.h:472
void ParseGridResizeParams(pybind11::args args, pybind11::kwargs kwargs, Size2 &resolution, Vector2D &gridSpacing, Vector2D &gridOrigin)
Definition: pybind11Utils.h:592
Point3UI ObjectToPoint3UI(const pybind11::object &obj)
Definition: pybind11Utils.h:412
T y
Y (or the second) component of the point.
Definition: Point2.h:34
T x
X (or the first) component of the vector.
Definition: Vector3.h:29
Definition: pybind11Utils.h:24
T z
Z (or the third) component of the vector.
Definition: Vector4.h:38
Vector3D TupleToVector3D(pybind11::tuple tuple)
Definition: pybind11Utils.h:304
void Set(T s)
Set both x and y components to s.
Definition: Vector2-Impl.h:28
T z
Z (or the third) component of the point.
Definition: Point3.h:38
Size2 ObjectToSize2(const pybind11::object &obj)
Definition: pybind11Utils.h:352
T y
Y (or the second) component of the point.
Definition: Point3.h:35
Point3UI TupleToPoint3UI(pybind11::tuple tuple)
Definition: pybind11Utils.h:140
T y
Y (or the second) component of the vector.
Definition: Vector2.h:35
4-D vector class.
Definition: Vector4.h:26
QuaternionF TupleToQuaternionF(pybind11::tuple tuple)
Definition: pybind11Utils.h:284
T x
X (or the first) component of the point.
Definition: Point3.h:29
2-D vector class.
Definition: Vector2.h:26
Vector3D ObjectToVector3D(const pybind11::object &obj)
Definition: pybind11Utils.h:492
Vector2F TupleToVector2F(pybind11::tuple tuple)
Definition: pybind11Utils.h:254
T x
X (or the first) component of the vector.
Definition: Vector4.h:29
Vector2D TupleToVector2D(pybind11::tuple tuple)
Definition: pybind11Utils.h:294
pybind11::tuple Size2ToTuple(const Size2 &size)
Definition: pybind11Utils.h:178
Vector4F TupleToVector4F(pybind11::tuple tuple)
Definition: pybind11Utils.h:274
Vector3F TupleToVector3F(pybind11::tuple tuple)
Definition: pybind11Utils.h:264
Point2UI ObjectToPoint2UI(const pybind11::object &obj)
Definition: pybind11Utils.h:392
Vector2F ObjectToVector2F(const pybind11::object &obj)
Definition: pybind11Utils.h:432
Vector4D TupleToVector4D(pybind11::tuple tuple)
Definition: pybind11Utils.h:314
T y
Y (or the second) component of the vector.
Definition: Vector3.h:35
QuaternionF ObjectToQuaternionF(const pybind11::object &obj)
Definition: pybind11Utils.h:552
Quaternion class defined as q = w + xi + yj + zk.
Definition: Quaternion.h:20
pybind11::tuple Vector2ToTuple(const Vector< T, 2 > &vec)
Definition: pybind11Utils.h:325
Vector< T, N > TupleToVector(pybind11::tuple tuple)
Definition: pybind11Utils.h:189