Blender  V3.3
VecMat.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include <iostream>
11 #include <math.h>
12 #include <vector>
13 
14 #ifdef WITH_CXX_GUARDEDALLOC
15 # include "MEM_guardedalloc.h"
16 #endif
17 
18 namespace Freestyle {
19 
20 namespace VecMat {
21 
22 namespace Internal {
23 template<bool B> struct is_false {
24 };
25 
26 template<> struct is_false<false> {
27  static inline void ensure()
28  {
29  }
30 };
31 } // end of namespace Internal
32 
33 //
34 // Vector class
35 // - T: value type
36 // - N: dimension
37 //
39 
40 template<class T, unsigned N> class Vec {
41  public:
42  typedef T value_type;
43 
44  // constructors
45  inline Vec()
46  {
47  for (unsigned int i = 0; i < N; i++) {
48  this->_coord[i] = 0;
49  }
50  }
51 
52  ~Vec()
53  {
54  Internal::is_false<(N == 0)>::ensure();
55  }
56 
57  template<class U> explicit inline Vec(const U tab[N])
58  {
59  for (unsigned int i = 0; i < N; i++) {
60  this->_coord[i] = (T)tab[i];
61  }
62  }
63 
64  template<class U> explicit inline Vec(const std::vector<U> &tab)
65  {
66  for (unsigned int i = 0; i < N; i++) {
67  this->_coord[i] = (T)tab[i];
68  }
69  }
70 
71  template<class U> explicit inline Vec(const Vec<U, N> &v)
72  {
73  for (unsigned int i = 0; i < N; i++) {
74  this->_coord[i] = (T)v[i];
75  }
76  }
77 
78  // accessors
79  inline value_type operator[](const unsigned i) const
80  {
81  return this->_coord[i];
82  }
83 
84  inline value_type &operator[](const unsigned i)
85  {
86  return this->_coord[i];
87  }
88 
89  static inline unsigned dim()
90  {
91  return N;
92  }
93 
94  // various useful methods
95  inline value_type norm() const
96  {
97  return (T)sqrt((float)squareNorm());
98  }
99 
100  inline value_type squareNorm() const
101  {
102  return (*this) * (*this);
103  }
104 
106  {
107  value_type n = norm();
108  for (unsigned int i = 0; i < N; i++) {
109  this->_coord[i] /= n;
110  }
111  return *this;
112  }
113 
115  {
116  value_type n = norm();
117  if (n) {
118  for (unsigned int i = 0; i < N; i++) {
119  this->_coord[i] /= n;
120  }
121  }
122  return *this;
123  }
124 
125  // classical operators
126  inline Vec<T, N> operator+(const Vec<T, N> &v) const
127  {
128  Vec<T, N> res(v);
129  res += *this;
130  return res;
131  }
132 
133  inline Vec<T, N> operator-(const Vec<T, N> &v) const
134  {
135  Vec<T, N> res(*this);
136  res -= v;
137  return res;
138  }
139 
140  inline Vec<T, N> operator*(const typename Vec<T, N>::value_type r) const
141  {
142  Vec<T, N> res(*this);
143  res *= r;
144  return res;
145  }
146 
147  inline Vec<T, N> operator/(const typename Vec<T, N>::value_type r) const
148  {
149  Vec<T, N> res(*this);
150  if (r) {
151  res /= r;
152  }
153  return res;
154  }
155 
156  // dot product
157  inline value_type operator*(const Vec<T, N> &v) const
158  {
159  value_type sum = 0;
160  for (unsigned int i = 0; i < N; i++) {
161  sum += (*this)[i] * v[i];
162  }
163  return sum;
164  }
165 
166  template<class U> inline Vec<T, N> &operator=(const Vec<U, N> &v)
167  {
168  if (this != &v) {
169  for (unsigned int i = 0; i < N; i++) {
170  this->_coord[i] = (T)v[i];
171  }
172  }
173  return *this;
174  }
175 
176  template<class U> inline Vec<T, N> &operator+=(const Vec<U, N> &v)
177  {
178  for (unsigned int i = 0; i < N; i++) {
179  this->_coord[i] += (T)v[i];
180  }
181  return *this;
182  }
183 
184  template<class U> inline Vec<T, N> &operator-=(const Vec<U, N> &v)
185  {
186  for (unsigned int i = 0; i < N; i++) {
187  this->_coord[i] -= (T)v[i];
188  }
189  return *this;
190  }
191 
192  template<class U> inline Vec<T, N> &operator*=(const U r)
193  {
194  for (unsigned int i = 0; i < N; i++) {
195  this->_coord[i] *= r;
196  }
197  return *this;
198  }
199 
200  template<class U> inline Vec<T, N> &operator/=(const U r)
201  {
202  if (r) {
203  for (unsigned int i = 0; i < N; i++) {
204  this->_coord[i] /= r;
205  }
206  }
207  return *this;
208  }
209 
210  inline bool operator==(const Vec<T, N> &v) const
211  {
212  for (unsigned int i = 0; i < N; i++) {
213  if (this->_coord[i] != v[i]) {
214  return false;
215  }
216  }
217  return true;
218  }
219 
220  inline bool operator!=(const Vec<T, N> &v) const
221  {
222  for (unsigned int i = 0; i < N; i++) {
223  if (this->_coord[i] != v[i]) {
224  return true;
225  }
226  }
227  return false;
228  }
229 
230  inline bool operator<(const Vec<T, N> &v) const
231  {
232  for (unsigned int i = 0; i < N; i++) {
233  if (this->_coord[i] < v[i]) {
234  return true;
235  }
236  if (this->_coord[i] > v[i]) {
237  return false;
238  }
239  if (this->_coord[i] == v[i]) {
240  continue;
241  }
242  }
243  return false;
244  }
245 
246  inline bool operator>(const Vec<T, N> &v) const
247  {
248  for (unsigned int i = 0; i < N; i++) {
249  if (this->_coord[i] > v[i]) {
250  return true;
251  }
252  if (this->_coord[i] < v[i]) {
253  return false;
254  }
255  if (this->_coord[i] == v[i]) {
256  continue;
257  }
258  }
259  return false;
260  }
261 
262  protected:
264  enum {
265  _dim = N,
266  };
267 
268 #ifdef WITH_CXX_GUARDEDALLOC
269  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:VecMat:Vec")
270 #endif
271 };
272 
273 //
274 // Vec2 class (2D Vector)
275 // - T: value type
276 //
278 
279 template<class T> class Vec2 : public Vec<T, 2> {
280  public:
282 
283  inline Vec2() : Vec<T, 2>()
284  {
285  }
286 
287  template<class U> explicit inline Vec2(const U tab[2]) : Vec<T, 2>(tab)
288  {
289  }
290 
291  template<class U> explicit inline Vec2(const std::vector<U> &tab) : Vec<T, 2>(tab)
292  {
293  }
294 
295  template<class U> inline Vec2(const Vec<U, 2> &v) : Vec<T, 2>(v)
296  {
297  }
298 
299  inline Vec2(const value_type x, const value_type y = 0) : Vec<T, 2>()
300  {
301  this->_coord[0] = (T)x;
302  this->_coord[1] = (T)y;
303  }
304 
305  inline value_type x() const
306  {
307  return this->_coord[0];
308  }
309 
310  inline value_type &x()
311  {
312  return this->_coord[0];
313  }
314 
315  inline value_type y() const
316  {
317  return this->_coord[1];
318  }
319 
320  inline value_type &y()
321  {
322  return this->_coord[1];
323  }
324 
325  inline void setX(const value_type v)
326  {
327  this->_coord[0] = v;
328  }
329 
330  inline void setY(const value_type v)
331  {
332  this->_coord[1] = v;
333  }
334 
335  // FIXME: hack swig -- no choice
336  inline Vec2<T> operator+(const Vec2<T> &v) const
337  {
338  Vec2<T> res(v);
339  res += *this;
340  return res;
341  }
342 
343  inline Vec2<T> operator-(const Vec2<T> &v) const
344  {
345  Vec2<T> res(*this);
346  res -= v;
347  return res;
348  }
349 
350  inline Vec2<T> operator*(const value_type r) const
351  {
352  Vec2<T> res(*this);
353  res *= r;
354  return res;
355  }
356 
357  inline Vec2<T> operator/(const value_type r) const
358  {
359  Vec2<T> res(*this);
360  if (r) {
361  res /= r;
362  }
363  return res;
364  }
365 
366  // dot product
367  inline value_type operator*(const Vec2<T> &v) const
368  {
369  value_type sum = 0;
370  for (unsigned int i = 0; i < 2; i++) {
371  sum += (*this)[i] * v[i];
372  }
373  return sum;
374  }
375 };
376 
377 //
378 // HVec3 class (3D Vector in homogeneous coordinates)
379 // - T: value type
380 //
382 
383 template<class T> class HVec3 : public Vec<T, 4> {
384  public:
386 
387  inline HVec3() : Vec<T, 4>()
388  {
389  }
390 
391  template<class U> explicit inline HVec3(const U tab[4]) : Vec<T, 4>(tab)
392  {
393  }
394 
395  template<class U> explicit inline HVec3(const std::vector<U> &tab) : Vec<T, 4>(tab)
396  {
397  }
398 
399  template<class U> inline HVec3(const Vec<U, 4> &v) : Vec<T, 4>(v)
400  {
401  }
402 
403  inline HVec3(const value_type sx,
404  const value_type sy = 0,
405  const value_type sz = 0,
406  const value_type s = 1)
407  {
408  this->_coord[0] = sx;
409  this->_coord[1] = sy;
410  this->_coord[2] = sz;
411  this->_coord[3] = s;
412  }
413 
414  template<class U> inline HVec3(const Vec<U, 3> &sv, const U s = 1)
415  {
416  this->_coord[0] = (T)sv[0];
417  this->_coord[1] = (T)sv[1];
418  this->_coord[2] = (T)sv[2];
419  this->_coord[3] = (T)s;
420  }
421 
422  inline value_type sx() const
423  {
424  return this->_coord[0];
425  }
426 
427  inline value_type &sx()
428  {
429  return this->_coord[0];
430  }
431 
432  inline value_type sy() const
433  {
434  return this->_coord[1];
435  }
436 
437  inline value_type &sy()
438  {
439  return this->_coord[1];
440  }
441 
442  inline value_type sz() const
443  {
444  return this->_coord[2];
445  }
446 
447  inline value_type &sz()
448  {
449  return this->_coord[2];
450  }
451 
452  inline value_type s() const
453  {
454  return this->_coord[3];
455  }
456 
457  inline value_type &s()
458  {
459  return this->_coord[3];
460  }
461 
462  // Access to non-homogeneous coordinates in 3D
463  inline value_type x() const
464  {
465  return this->_coord[0] / this->_coord[3];
466  }
467 
468  inline value_type y() const
469  {
470  return this->_coord[1] / this->_coord[3];
471  }
472 
473  inline value_type z() const
474  {
475  return this->_coord[2] / this->_coord[3];
476  }
477 };
478 
479 //
480 // Vec3 class (3D Vec)
481 // - T: value type
482 //
484 template<class T> class Vec3 : public Vec<T, 3> {
485  public:
487 
488  inline Vec3() : Vec<T, 3>()
489  {
490  }
491 
492  template<class U> explicit inline Vec3(const U tab[3]) : Vec<T, 3>(tab)
493  {
494  }
495 
496  template<class U> explicit inline Vec3(const std::vector<U> &tab) : Vec<T, 3>(tab)
497  {
498  }
499 
500  template<class U> inline Vec3(const Vec<U, 3> &v) : Vec<T, 3>(v)
501  {
502  }
503 
504  template<class U> inline Vec3(const HVec3<U> &v)
505  {
506  this->_coord[0] = (T)v.x();
507  this->_coord[1] = (T)v.y();
508  this->_coord[2] = (T)v.z();
509  }
510 
511  inline Vec3(const value_type x, const value_type y = 0, const value_type z = 0) : Vec<T, 3>()
512  {
513  this->_coord[0] = x;
514  this->_coord[1] = y;
515  this->_coord[2] = z;
516  }
517 
518  inline value_type x() const
519  {
520  return this->_coord[0];
521  }
522 
523  inline value_type &x()
524  {
525  return this->_coord[0];
526  }
527 
528  inline value_type y() const
529  {
530  return this->_coord[1];
531  }
532 
533  inline value_type &y()
534  {
535  return this->_coord[1];
536  }
537 
538  inline value_type z() const
539  {
540  return this->_coord[2];
541  }
542 
543  inline value_type &z()
544  {
545  return this->_coord[2];
546  }
547 
548  inline void setX(const value_type v)
549  {
550  this->_coord[0] = v;
551  }
552 
553  inline void setY(const value_type v)
554  {
555  this->_coord[1] = v;
556  }
557 
558  inline void setZ(const value_type v)
559  {
560  this->_coord[2] = v;
561  }
562 
563  // classical operators
564  // FIXME: hack swig -- no choice
565  inline Vec3<T> operator+(const Vec3<T> &v) const
566  {
567  Vec3<T> res(v);
568  res += *this;
569  return res;
570  }
571 
572  inline Vec3<T> operator-(const Vec3<T> &v) const
573  {
574  Vec3<T> res(*this);
575  res -= v;
576  return res;
577  }
578 
579  inline Vec3<T> operator*(const value_type r) const
580  {
581  Vec3<T> res(*this);
582  res *= r;
583  return res;
584  }
585 
586  inline Vec3<T> operator/(const value_type r) const
587  {
588  Vec3<T> res(*this);
589  if (r) {
590  res /= r;
591  }
592  return res;
593  }
594 
595  // dot product
596  inline value_type operator*(const Vec3<T> &v) const
597  {
598  value_type sum = 0;
599  for (unsigned int i = 0; i < 3; i++) {
600  sum += (*this)[i] * v[i];
601  }
602  return sum;
603  }
604 
605  // cross product for 3D Vectors
606  // FIXME: hack swig -- no choice
607  inline Vec3<T> operator^(const Vec3<T> &v) const
608  {
609  Vec3<T> res((*this)[1] * v[2] - (*this)[2] * v[1],
610  (*this)[2] * v[0] - (*this)[0] * v[2],
611  (*this)[0] * v[1] - (*this)[1] * v[0]);
612  return res;
613  }
614 
615  // cross product for 3D Vectors
616  template<typename U> inline Vec3<T> operator^(const Vec<U, 3> &v) const
617  {
618  Vec3<T> res((*this)[1] * v[2] - (*this)[2] * v[1],
619  (*this)[2] * v[0] - (*this)[0] * v[2],
620  (*this)[0] * v[1] - (*this)[1] * v[0]);
621  return res;
622  }
623 };
624 
625 //
626 // Matrix class
627 // - T: value type
628 // - M: rows
629 // - N: cols
630 //
632 
633 // Dirty, but icc under Windows needs this
634 #define _SIZE (M * N)
635 
636 template<class T, unsigned M, unsigned N> class Matrix {
637  public:
638  typedef T value_type;
639 
640  inline Matrix()
641  {
642  for (unsigned int i = 0; i < _SIZE; i++) {
643  this->_coord[i] = 0;
644  }
645  }
646 
648  {
649  Internal::is_false<(M == 0)>::ensure();
650  Internal::is_false<(N == 0)>::ensure();
651  }
652 
653  template<class U> explicit inline Matrix(const U tab[_SIZE])
654  {
655  for (unsigned int i = 0; i < _SIZE; i++) {
656  this->_coord[i] = tab[i];
657  }
658  }
659 
660  template<class U> explicit inline Matrix(const std::vector<U> &tab)
661  {
662  for (unsigned int i = 0; i < _SIZE; i++) {
663  this->_coord[i] = tab[i];
664  }
665  }
666 
667  template<class U> inline Matrix(const Matrix<U, M, N> &m)
668  {
669  for (unsigned int i = 0; i < M; i++) {
670  for (unsigned int j = 0; j < N; j++) {
671  this->_coord[i * N + j] = (T)m(i, j);
672  }
673  }
674  }
675 
676  inline value_type operator()(const unsigned i, const unsigned j) const
677  {
678  return this->_coord[i * N + j];
679  }
680 
681  inline value_type &operator()(const unsigned i, const unsigned j)
682  {
683  return this->_coord[i * N + j];
684  }
685 
686  static inline unsigned rows()
687  {
688  return M;
689  }
690 
691  static inline unsigned cols()
692  {
693  return N;
694  }
695 
696  inline Matrix<T, M, N> &transpose() const
697  {
698  Matrix<T, N, M> res;
699  for (unsigned int i = 0; i < M; i++) {
700  for (unsigned int j = 0; j < N; j++) {
701  res(j, i) = this->_coord[i * N + j];
702  }
703  }
704  *this = res;
705  return *this;
706  }
707 
708  template<class U> inline Matrix<T, M, N> &operator=(const Matrix<U, M, N> &m)
709  {
710  if (this != &m) {
711  for (unsigned int i = 0; i < M; i++) {
712  for (unsigned int j = 0; j < N; j++) {
713  this->_coord[i * N + j] = (T)m(i, j);
714  }
715  }
716  }
717  return *this;
718  }
719 
720  template<class U> inline Matrix<T, M, N> &operator+=(const Matrix<U, M, N> &m)
721  {
722  for (unsigned int i = 0; i < M; i++) {
723  for (unsigned int j = 0; j < N; j++) {
724  this->_coord[i * N + j] += (T)m(i, j);
725  }
726  }
727  return *this;
728  }
729 
730  template<class U> inline Matrix<T, M, N> &operator-=(const Matrix<U, M, N> &m)
731  {
732  for (unsigned int i = 0; i < M; i++) {
733  for (unsigned int j = 0; j < N; j++) {
734  this->_coord[i * N + j] -= (T)m(i, j);
735  }
736  }
737  return *this;
738  }
739 
740  template<class U> inline Matrix<T, M, N> &operator*=(const U lambda)
741  {
742  for (unsigned int i = 0; i < M; i++) {
743  for (unsigned int j = 0; j < N; j++) {
744  this->_coord[i * N + j] *= lambda;
745  }
746  }
747  return *this;
748  }
749 
750  template<class U> inline Matrix<T, M, N> &operator/=(const U lambda)
751  {
752  if (lambda) {
753  for (unsigned int i = 0; i < M; i++) {
754  for (unsigned int j = 0; j < N; j++) {
755  this->_coord[i * N + j] /= lambda;
756  }
757  }
758  }
759  return *this;
760  }
761 
762  protected:
764 
765 #ifdef WITH_CXX_GUARDEDALLOC
766  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:VecMat:Matrix")
767 #endif
768 };
769 
770 #undef _SIZE
771 
772 //
773 // SquareMatrix class
774 // - T: value type
775 // - N: rows & cols
776 //
778 
779 // Dirty, but icc under Windows needs this
780 #define _SIZE (N * N)
781 
782 template<class T, unsigned N> class SquareMatrix : public Matrix<T, N, N> {
783  public:
784  typedef T value_type;
785 
786  inline SquareMatrix() : Matrix<T, N, N>()
787  {
788  }
789 
790  template<class U> explicit inline SquareMatrix(const U tab[_SIZE]) : Matrix<T, N, N>(tab)
791  {
792  }
793 
794  template<class U> explicit inline SquareMatrix(const std::vector<U> &tab) : Matrix<T, N, N>(tab)
795  {
796  }
797 
798  template<class U> inline SquareMatrix(const Matrix<U, N, N> &m) : Matrix<T, N, N>(m)
799  {
800  }
801 
802  static inline SquareMatrix<T, N> identity()
803  {
804  SquareMatrix<T, N> res;
805  for (unsigned int i = 0; i < N; i++) {
806  res(i, i) = 1;
807  }
808  return res;
809  }
810 };
811 
812 #undef _SIZE
813 
814 //
815 // Vector external functions
816 //
818 
819 #if 0
820 template<class T, unsigned N> inline Vec<T, N> operator+(const Vec<T, N> &v1, const Vec<T, N> &v2)
821 {
822  Vec<T, N> res(v1);
823  res += v2;
824  return res;
825 }
826 
827 template<class T, unsigned N> inline Vec<T, N> operator-(const Vec<T, N> &v1, const Vec<T, N> &v2)
828 {
829  Vec<T, N> res(v1);
830  res -= v2;
831  return res;
832 }
833 
834 template<class T, unsigned N>
835 inline Vec<T, N> operator*(const Vec<T, N> &v, const typename Vec<T, N>::value_type r)
836 {
837  Vec<T, N> res(v);
838  res *= r;
839  return res;
840 }
841 #endif
842 
843 template<class T, unsigned N>
844 inline Vec<T, N> operator*(const typename Vec<T, N>::value_type r, const Vec<T, N> &v)
845 {
846  Vec<T, N> res(v);
847  res *= r;
848  return res;
849 }
850 
851 #if 0
852 template<class T, unsigned N>
853 inline Vec<T, N> operator/(const Vec<T, N> &v, const typename Vec<T, N>::value_type r)
854 {
855  Vec<T, N> res(v);
856  if (r) {
857  res /= r;
858  }
859  return res;
860 }
861 
862 // dot product
863 template<class T, unsigned N>
864 inline typename Vec<T, N>::value_type operator*(const Vec<T, N> &v1, const Vec<T, N> &v2)
865 {
866  typename Vec<T, N>::value_type sum = 0;
867  for (unsigned int i = 0; i < N; i++) {
868  sum += v1[i] * v2[i];
869  }
870  return sum;
871 }
872 
873 // cross product for 3D Vectors
874 template<typename T> inline Vec3<T> operator^(const Vec<T, 3> &v1, const Vec<T, 3> &v2)
875 {
876  Vec3<T> res(
877  v1[1] * v2[2] - v1[2] * v2[1], v1[2] * v2[0] - v1[0] * v2[2], v1[0] * v2[1] - v1[1] * v2[0]);
878  return res;
879 }
880 #endif
881 
882 // stream operator
883 template<class T, unsigned N> inline std::ostream &operator<<(std::ostream &s, const Vec<T, N> &v)
884 {
885  unsigned int i;
886  s << "[";
887  for (i = 0; i < N - 1; i++) {
888  s << v[i] << ", ";
889  }
890  s << v[i] << "]";
891  return s;
892 }
893 
894 //
895 // Matrix external functions
896 //
898 
899 template<class T, unsigned M, unsigned N>
901 {
902  Matrix<T, M, N> res(m1);
903  res += m2;
904  return res;
905 }
906 
907 template<class T, unsigned M, unsigned N>
909 {
910  Matrix<T, M, N> res(m1);
911  res -= m2;
912  return res;
913 }
914 
915 template<class T, unsigned M, unsigned N>
917  const typename Matrix<T, M, N>::value_type lambda)
918 {
919  Matrix<T, M, N> res(m1);
920  res *= lambda;
921  return res;
922 }
923 
924 template<class T, unsigned M, unsigned N>
926  const Matrix<T, M, N> &m1)
927 {
928  Matrix<T, M, N> res(m1);
929  res *= lambda;
930  return res;
931 }
932 
933 template<class T, unsigned M, unsigned N>
935  const typename Matrix<T, M, N>::value_type lambda)
936 {
937  Matrix<T, M, N> res(m1);
938  res /= lambda;
939  return res;
940 }
941 
942 template<class T, unsigned M, unsigned N, unsigned P>
944 {
945  unsigned int i, j, k;
946  Matrix<T, M, P> res;
947  typename Matrix<T, N, P>::value_type scale;
948 
949  for (j = 0; j < P; j++) {
950  for (k = 0; k < N; k++) {
951  scale = m2(k, j);
952  for (i = 0; i < N; i++) {
953  res(i, j) += m1(i, k) * scale;
954  }
955  }
956  }
957  return res;
958 }
959 
960 template<class T, unsigned M, unsigned N>
962 {
963  Vec<T, M> res;
964  typename Matrix<T, M, N>::value_type scale;
965 
966  for (unsigned int j = 0; j < M; j++) {
967  scale = v[j];
968  for (unsigned int i = 0; i < N; i++) {
969  res[i] += m(i, j) * scale;
970  }
971  }
972  return res;
973 }
974 
975 // stream operator
976 template<class T, unsigned M, unsigned N>
977 inline std::ostream &operator<<(std::ostream &s, const Matrix<T, M, N> &m)
978 {
979  unsigned int i, j;
980  for (i = 0; i < M; i++) {
981  s << "[";
982  for (j = 0; j < N - 1; j++) {
983  s << m(i, j) << ", ";
984  }
985  s << m(i, j) << "]" << std::endl;
986  }
987  return s;
988 }
989 
990 } // end of namespace VecMat
991 
992 } /* namespace Freestyle */
sqrt(x)+1/max(0
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define _SIZE
Definition: VecMat.h:780
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
unsigned int U
Definition: btGjkEpa3.h:78
static T sum(const btAlignedObjectArray< T > &items)
value_type z() const
Definition: VecMat.h:473
value_type & sy()
Definition: VecMat.h:437
HVec3(const Vec< U, 4 > &v)
Definition: VecMat.h:399
value_type & sx()
Definition: VecMat.h:427
HVec3(const std::vector< U > &tab)
Definition: VecMat.h:395
HVec3(const Vec< U, 3 > &sv, const U s=1)
Definition: VecMat.h:414
value_type x() const
Definition: VecMat.h:463
value_type sy() const
Definition: VecMat.h:432
value_type sx() const
Definition: VecMat.h:422
HVec3(const U tab[4])
Definition: VecMat.h:391
HVec3(const value_type sx, const value_type sy=0, const value_type sz=0, const value_type s=1)
Definition: VecMat.h:403
value_type & sz()
Definition: VecMat.h:447
value_type sz() const
Definition: VecMat.h:442
value_type s() const
Definition: VecMat.h:452
value_type y() const
Definition: VecMat.h:468
value_type & s()
Definition: VecMat.h:457
Vec< T, 4 >::value_type value_type
Definition: VecMat.h:385
Matrix< T, M, N > & operator+=(const Matrix< U, M, N > &m)
Definition: VecMat.h:720
Matrix(const std::vector< U > &tab)
Definition: VecMat.h:660
Matrix(const Matrix< U, M, N > &m)
Definition: VecMat.h:667
Matrix< T, M, N > & operator=(const Matrix< U, M, N > &m)
Definition: VecMat.h:708
Matrix< T, M, N > & operator-=(const Matrix< U, M, N > &m)
Definition: VecMat.h:730
static unsigned rows()
Definition: VecMat.h:686
Matrix(const U tab[_SIZE])
Definition: VecMat.h:653
Matrix< T, M, N > & transpose() const
Definition: VecMat.h:696
Matrix< T, M, N > & operator/=(const U lambda)
Definition: VecMat.h:750
value_type _coord[_SIZE]
Definition: VecMat.h:763
Matrix< T, M, N > & operator*=(const U lambda)
Definition: VecMat.h:740
static unsigned cols()
Definition: VecMat.h:691
value_type operator()(const unsigned i, const unsigned j) const
Definition: VecMat.h:676
value_type & operator()(const unsigned i, const unsigned j)
Definition: VecMat.h:681
static SquareMatrix< T, N > identity()
Definition: VecMat.h:802
SquareMatrix(const std::vector< U > &tab)
Definition: VecMat.h:794
SquareMatrix(const Matrix< U, N, N > &m)
Definition: VecMat.h:798
SquareMatrix(const U tab[_SIZE])
Definition: VecMat.h:790
value_type operator*(const Vec2< T > &v) const
Definition: VecMat.h:367
void setX(const value_type v)
Definition: VecMat.h:325
value_type x() const
Definition: VecMat.h:305
Vec2< T > operator*(const value_type r) const
Definition: VecMat.h:350
value_type & y()
Definition: VecMat.h:320
Vec2(const U tab[2])
Definition: VecMat.h:287
Vec2< T > operator/(const value_type r) const
Definition: VecMat.h:357
value_type & x()
Definition: VecMat.h:310
Vec2(const Vec< U, 2 > &v)
Definition: VecMat.h:295
value_type y() const
Definition: VecMat.h:315
Vec2< T > operator-(const Vec2< T > &v) const
Definition: VecMat.h:343
void setY(const value_type v)
Definition: VecMat.h:330
Vec2< T > operator+(const Vec2< T > &v) const
Definition: VecMat.h:336
Vec< T, 2 >::value_type value_type
Definition: VecMat.h:281
Vec2(const value_type x, const value_type y=0)
Definition: VecMat.h:299
Vec2(const std::vector< U > &tab)
Definition: VecMat.h:291
value_type & x()
Definition: VecMat.h:523
Vec3< T > operator-(const Vec3< T > &v) const
Definition: VecMat.h:572
Vec3(const std::vector< U > &tab)
Definition: VecMat.h:496
value_type & y()
Definition: VecMat.h:533
void setX(const value_type v)
Definition: VecMat.h:548
Vec3< T > operator^(const Vec< U, 3 > &v) const
Definition: VecMat.h:616
value_type x() const
Definition: VecMat.h:518
value_type operator*(const Vec3< T > &v) const
Definition: VecMat.h:596
void setY(const value_type v)
Definition: VecMat.h:553
Vec< T, 3 >::value_type value_type
Definition: VecMat.h:486
Vec3< T > operator*(const value_type r) const
Definition: VecMat.h:579
value_type z() const
Definition: VecMat.h:538
Vec3(const U tab[3])
Definition: VecMat.h:492
Vec3(const value_type x, const value_type y=0, const value_type z=0)
Definition: VecMat.h:511
value_type y() const
Definition: VecMat.h:528
Vec3(const HVec3< U > &v)
Definition: VecMat.h:504
void setZ(const value_type v)
Definition: VecMat.h:558
Vec3< T > operator+(const Vec3< T > &v) const
Definition: VecMat.h:565
Vec3< T > operator^(const Vec3< T > &v) const
Definition: VecMat.h:607
Vec3(const Vec< U, 3 > &v)
Definition: VecMat.h:500
value_type & z()
Definition: VecMat.h:543
Vec3< T > operator/(const value_type r) const
Definition: VecMat.h:586
value_type squareNorm() const
Definition: VecMat.h:100
Vec(const U tab[N])
Definition: VecMat.h:57
Vec< T, N > operator+(const Vec< T, N > &v) const
Definition: VecMat.h:126
Vec< T, N > & operator/=(const U r)
Definition: VecMat.h:200
Vec< T, N > & operator-=(const Vec< U, N > &v)
Definition: VecMat.h:184
Vec< T, N > operator-(const Vec< T, N > &v) const
Definition: VecMat.h:133
static unsigned dim()
Definition: VecMat.h:89
value_type operator[](const unsigned i) const
Definition: VecMat.h:79
Vec< T, N > & normalizeSafe()
Definition: VecMat.h:114
Vec< T, N > & operator+=(const Vec< U, N > &v)
Definition: VecMat.h:176
Vec< T, N > & operator=(const Vec< U, N > &v)
Definition: VecMat.h:166
Vec< T, N > & operator*=(const U r)
Definition: VecMat.h:192
value_type & operator[](const unsigned i)
Definition: VecMat.h:84
bool operator>(const Vec< T, N > &v) const
Definition: VecMat.h:246
Vec< T, N > operator*(const typename Vec< T, N >::value_type r) const
Definition: VecMat.h:140
Vec(const Vec< U, N > &v)
Definition: VecMat.h:71
bool operator!=(const Vec< T, N > &v) const
Definition: VecMat.h:220
Vec< T, N > operator/(const typename Vec< T, N >::value_type r) const
Definition: VecMat.h:147
bool operator==(const Vec< T, N > &v) const
Definition: VecMat.h:210
value_type operator*(const Vec< T, N > &v) const
Definition: VecMat.h:157
value_type _coord[N]
Definition: VecMat.h:263
Vec(const std::vector< U > &tab)
Definition: VecMat.h:64
value_type norm() const
Definition: VecMat.h:95
bool operator<(const Vec< T, N > &v) const
Definition: VecMat.h:230
Vec< T, N > & normalize()
Definition: VecMat.h:105
static float P(float k)
Definition: math_interp.c:25
#define M
#define N
#define T
Matrix< T, M, N > operator-(const Matrix< T, M, N > &m1, const Matrix< T, M, N > &m2)
Definition: VecMat.h:908
std::ostream & operator<<(std::ostream &s, const Vec< T, N > &v)
Definition: VecMat.h:883
Matrix< T, M, N > operator/(const Matrix< T, M, N > &m1, const typename Matrix< T, M, N >::value_type lambda)
Definition: VecMat.h:934
Vec< T, N > operator*(const typename Vec< T, N >::value_type r, const Vec< T, N > &v)
Definition: VecMat.h:844
Matrix< T, M, N > operator+(const Matrix< T, M, N > &m1, const Matrix< T, M, N > &m2)
Definition: VecMat.h:900
inherits from class Rep
Definition: AppCanvas.cpp:18
GPUState operator^(const GPUState &a, const GPUState &b)