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