32 #ifndef Matrix4_INCLUDE_ONCE 33 #define Matrix4_INCLUDE_ONCE 47 template<
typename T_Scalar>
56 e(0,0) = (T_Scalar)m.
e(0,0);
e(1,0) = (T_Scalar)m.
e(1,0);
e(2,0) = (T_Scalar)m.
e(2,0);
e(3,0) = (T_Scalar)m.
e(3,0);
57 e(0,1) = (T_Scalar)m.
e(0,1);
e(1,1) = (T_Scalar)m.
e(1,1);
e(2,1) = (T_Scalar)m.
e(2,1);
e(3,1) = (T_Scalar)m.
e(3,1);
58 e(0,2) = (T_Scalar)m.
e(0,2);
e(1,2) = (T_Scalar)m.
e(1,2);
e(2,2) = (T_Scalar)m.
e(2,2);
e(3,2) = (T_Scalar)m.
e(3,2);
59 e(0,3) = (T_Scalar)m.
e(0,3);
e(1,3) = (T_Scalar)m.
e(1,3);
e(2,3) = (T_Scalar)m.
e(2,3);
e(3,3) = (T_Scalar)m.
e(3,3);
75 e(0,0) =
e(1,1) =
e(2,2) =
e(3,3) = n;
83 explicit Matrix4( T_Scalar e00, T_Scalar e01, T_Scalar e02, T_Scalar e03,
84 T_Scalar e10, T_Scalar e11, T_Scalar e12, T_Scalar e13,
85 T_Scalar e20, T_Scalar e21, T_Scalar e22, T_Scalar e23,
86 T_Scalar e30, T_Scalar e31, T_Scalar e32, T_Scalar e33)
88 e(0,0) = e00;
e(0,1) = e01;
e(0,2) = e02;
e(0,3) = e03;
89 e(1,0) = e10;
e(1,1) = e11;
e(1,2) = e12;
e(1,3) = e13;
90 e(2,0) = e20;
e(2,1) = e21;
e(2,2) = e22;
e(2,3) = e23;
91 e(3,0) = e30;
e(3,1) = e31;
e(3,2) = e32;
e(3,3) = e33;
96 e(0,0) =
e(1,0) =
e(2,0) =
e(3,0) =
97 e(0,1) =
e(1,1) =
e(2,1) =
e(3,1) =
98 e(0,2) =
e(1,2) =
e(2,2) =
e(3,2) =
99 e(0,3) =
e(1,3) =
e(2,3) =
e(3,3) = val;
105 memcpy(
ptr(), val,
sizeof(T_Scalar)*16);
112 for(
int i=0; i<4; ++i)
113 for(
int j=0; j<4; ++j)
114 if (
e(j,i) > other.
e(j,i))
115 err +=
e(j,i) - other.
e(j,i);
117 err += other.
e(j,i) -
e(j,i);
175 return memcmp(m.
mVec,
mVec,
sizeof(T_Scalar)*4*4) == 0;
185 memcpy(
mVec, m.
mVec,
sizeof(T_Scalar)*16);
192 for(
int i=0; i<4; ++i)
193 for(
int j=0; j<4; ++j)
194 t.
e(j,i) =
e(j,i) + m.
e(j,i);
201 for(
int i=0; i<4; ++i)
202 for(
int j=0; j<4; ++j)
210 for(
int i=0; i<4; ++i)
211 for(
int j=0; j<4; ++j)
212 t.
e(j,i) =
e(j,i) - m.
e(j,i);
219 for(
int i=0; i<4; ++i)
220 for(
int j=0; j<4; ++j)
233 for(
int i=0; i<4; ++i)
234 for(
int j=0; j<4; ++j)
242 for(
int i=0; i<4; ++i)
243 for(
int j=0; j<4; ++j)
244 t.
e(j,i) =
e(j,i) + d;
250 for(
int i=0; i<4; ++i)
251 for(
int j=0; j<4; ++j)
259 for(
int i=0; i<4; ++i)
260 for(
int j=0; j<4; ++j)
261 t.
e(j,i) =
e(j,i) - d;
267 for(
int i=0; i<4; ++i)
268 for(
int j=0; j<4; ++j)
276 for(
int i=0; i<4; ++i)
277 for(
int j=0; j<4; ++j)
278 t.
e(j,i) =
e(j,i) * d;
284 for(
int i=0; i<4; ++i)
285 for(
int j=0; j<4; ++j)
294 for(
int i=0; i<4; ++i)
295 for(
int j=0; j<4; ++j)
296 t.
e(j,i) =
e(j,i) * d;
303 for(
int i=0; i<4; ++i)
304 for(
int j=0; j<4; ++j)
312 return memcmp(
ptr(), i.
ptr(),
sizeof(T_Scalar)*16) == 0;
331 t.
e(0,0) =
e(0,0); t.
e(1,0) =
e(1,0); t.
e(2,0) =
e(2,0);
332 t.
e(0,1) =
e(0,1); t.
e(1,1) =
e(1,1); t.
e(2,1) =
e(2,1);
333 t.
e(0,2) =
e(0,2); t.
e(1,2) =
e(1,2); t.
e(2,2) =
e(2,2);
340 e(0,0) = m.
e(0,0);
e(1,0) = m.
e(1,0);
e(2,0) = m.
e(2,0);
341 e(0,1) = m.
e(0,1);
e(1,1) = m.
e(1,1);
e(2,1) = m.
e(2,1);
342 e(0,2) = m.
e(0,2);
e(1,2) = m.
e(1,2);
e(2,2) = m.
e(2,2);
350 const T_Scalar*
ptr()
const 358 for(
int i=0; i<4; ++i)
359 for(
int j=i; j<4; ++j)
371 for(
int i=0; i<4; ++i)
372 for(
int j=0; j<4; ++j)
379 for(
int i=0; i<4; ++i)
380 for(
int j=0; j<4; ++j)
381 dest.
e(j,i) =
e(i,j);
387 for(
int i=0; i<4; ++i)
388 for(
int j=0; j<4; ++j)
413 static const T_Scalar I4d[] =
415 (T_Scalar)1, (T_Scalar)0, (T_Scalar)0, (T_Scalar)0,
416 (T_Scalar)0, (T_Scalar)1, (T_Scalar)0, (T_Scalar)0,
417 (T_Scalar)0, (T_Scalar)0, (T_Scalar)1, (T_Scalar)0,
418 (T_Scalar)0, (T_Scalar)0, (T_Scalar)0, (T_Scalar)1
420 memcpy(
mVec, I4d,
sizeof(T_Scalar)*16);
456 static Matrix4 getFrustum(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop, T_Scalar pnear, T_Scalar pfar);
458 static Matrix4 getOrtho(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop, T_Scalar pnear, T_Scalar pfar);
460 static Matrix4 getOrtho2D(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop);
497 return rotate(degrees, v.
x(), v.
y(), v.
z());
629 out.
e(0,0) = q.
e(0,0)*p.
e(0,0) + q.
e(1,0)*p.
e(0,1) + q.
e(2,0)*p.
e(0,2) + q.
e(3,0)*p.
e(0,3);
630 out.
e(0,1) = q.
e(0,1)*p.
e(0,0) + q.
e(1,1)*p.
e(0,1) + q.
e(2,1)*p.
e(0,2) + q.
e(3,1)*p.
e(0,3);
631 out.
e(0,2) = q.
e(0,2)*p.
e(0,0) + q.
e(1,2)*p.
e(0,1) + q.
e(2,2)*p.
e(0,2) + q.
e(3,2)*p.
e(0,3);
632 out.
e(0,3) = q.
e(0,3)*p.
e(0,0) + q.
e(1,3)*p.
e(0,1) + q.
e(2,3)*p.
e(0,2) + q.
e(3,3)*p.
e(0,3);
634 out.
e(1,0) = q.
e(0,0)*p.
e(1,0) + q.
e(1,0)*p.
e(1,1) + q.
e(2,0)*p.
e(1,2) + q.
e(3,0)*p.
e(1,3);
635 out.
e(1,1) = q.
e(0,1)*p.
e(1,0) + q.
e(1,1)*p.
e(1,1) + q.
e(2,1)*p.
e(1,2) + q.
e(3,1)*p.
e(1,3);
636 out.
e(1,2) = q.
e(0,2)*p.
e(1,0) + q.
e(1,2)*p.
e(1,1) + q.
e(2,2)*p.
e(1,2) + q.
e(3,2)*p.
e(1,3);
637 out.
e(1,3) = q.
e(0,3)*p.
e(1,0) + q.
e(1,3)*p.
e(1,1) + q.
e(2,3)*p.
e(1,2) + q.
e(3,3)*p.
e(1,3);
639 out.
e(2,0) = q.
e(0,0)*p.
e(2,0) + q.
e(1,0)*p.
e(2,1) + q.
e(2,0)*p.
e(2,2) + q.
e(3,0)*p.
e(2,3);
640 out.
e(2,1) = q.
e(0,1)*p.
e(2,0) + q.
e(1,1)*p.
e(2,1) + q.
e(2,1)*p.
e(2,2) + q.
e(3,1)*p.
e(2,3);
641 out.
e(2,2) = q.
e(0,2)*p.
e(2,0) + q.
e(1,2)*p.
e(2,1) + q.
e(2,2)*p.
e(2,2) + q.
e(3,2)*p.
e(2,3);
642 out.
e(2,3) = q.
e(0,3)*p.
e(2,0) + q.
e(1,3)*p.
e(2,1) + q.
e(2,3)*p.
e(2,2) + q.
e(3,3)*p.
e(2,3);
644 out.
e(3,0) = q.
e(0,0)*p.
e(3,0) + q.
e(1,0)*p.
e(3,1) + q.
e(2,0)*p.
e(3,2) + q.
e(3,0)*p.
e(3,3);
645 out.
e(3,1) = q.
e(0,1)*p.
e(3,0) + q.
e(1,1)*p.
e(3,1) + q.
e(2,1)*p.
e(3,2) + q.
e(3,1)*p.
e(3,3);
646 out.
e(3,2) = q.
e(0,2)*p.
e(3,0) + q.
e(1,2)*p.
e(3,1) + q.
e(2,2)*p.
e(3,2) + q.
e(3,2)*p.
e(3,3);
647 out.
e(3,3) = q.
e(0,3)*p.
e(3,0) + q.
e(1,3)*p.
e(3,1) + q.
e(2,3)*p.
e(3,2) + q.
e(3,3)*p.
e(3,3);
655 return *
this =
multiply(t, *
this, m);
661 return *
this =
multiply(t, m, *
this);
665 const T_Scalar&
e(
int i,
int j)
const {
return mVec[j][i]; }
666 T_Scalar&
e(
int i,
int j) {
return mVec[j][i]; }
678 template<
typename T_Scalar>
686 template<
typename T_Scalar>
692 template<
typename T_Scalar>
699 template<
typename T_Scalar>
703 v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) + v.
z()*m.
e(0,2) + v.
w()*m.
e(0,3),
704 v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) + v.
z()*m.
e(1,2) + v.
w()*m.
e(1,3),
705 v.
x()*m.
e(2,0) + v.
y()*m.
e(2,1) + v.
z()*m.
e(2,2) + v.
w()*m.
e(2,3),
706 v.
x()*m.
e(3,0) + v.
y()*m.
e(3,1) + v.
z()*m.
e(3,2) + v.
w()*m.
e(3,3)
712 template<
typename T_Scalar>
716 v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) + v.
z()*m.
e(0,2) + m.
e(0,3),
717 v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) + v.
z()*m.
e(1,2) + m.
e(1,3),
718 v.
x()*m.
e(2,0) + v.
y()*m.
e(2,1) + v.
z()*m.
e(2,2) + m.
e(2,3)
724 template<
typename T_Scalar>
728 v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) + m.
e(0,3),
729 v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) + m.
e(1,3)
734 template<
typename T_Scalar>
738 v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) + v.
z()*m.
e(2,0) + v.
w()*m.
e(3,0),
739 v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) + v.
z()*m.
e(2,1) + v.
w()*m.
e(3,1),
740 v.
x()*m.
e(0,2) + v.
y()*m.
e(1,2) + v.
z()*m.
e(2,2) + v.
w()*m.
e(3,2),
741 v.
x()*m.
e(0,3) + v.
y()*m.
e(1,3) + v.
z()*m.
e(2,3) + v.
w()*m.
e(3,3)
747 template<
typename T_Scalar>
751 v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) + v.
z()*m.
e(2,0) + m.
e(3,0),
752 v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) + v.
z()*m.
e(2,1) + m.
e(3,1),
753 v.
x()*m.
e(0,2) + v.
y()*m.
e(1,2) + v.
z()*m.
e(2,2) + m.
e(3,2)
759 template<
typename T_Scalar>
763 v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) + m.
e(3,0),
764 v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) + m.
e(3,1)
768 template<
typename T_Scalar>
776 T_Scalar la_modeling[] =
778 xaxis.
x() , xaxis.
y() , xaxis.
z() , 0,
779 yaxis.
x() , yaxis.
y() , yaxis.
z() , 0,
780 zaxis.
x() , zaxis.
y() , zaxis.
z() , 0,
781 eye.
x() , eye.
y() , eye.
z() , 1
787 template<
typename T_Scalar>
797 xaxis.
x() , yaxis.
x() , zaxis.
x() , 0,
798 xaxis.
y() , yaxis.
y() , zaxis.
y() , 0,
799 xaxis.
z() , yaxis.
z() , zaxis.
z() , 0,
800 -
dot(xaxis,eye), -
dot(yaxis,eye), -
dot(zaxis,eye), 1
806 template<
typename T_Scalar>
821 template<
typename T_Scalar>
829 template<
typename T_Scalar>
834 T_Scalar rads = (fovy / ((T_Scalar)2)) * (T_Scalar)
dDEG_TO_RAD;
835 T_Scalar dz = zfar - znear;
836 T_Scalar sa =
sin(rads);
837 if ((dz == 0) || (sa == 0) || (aspect_ratio == 0))
839 T_Scalar ctan =
cos(rads) / sa;
841 m.
e(0,0) = (T_Scalar)(ctan / aspect_ratio);
842 m.
e(1,1) = (T_Scalar)(ctan);
843 m.
e(2,2) = (T_Scalar)(-(zfar + znear) / dz);
844 m.
e(3,2) = -((T_Scalar)1);
845 m.
e(2,3) = (T_Scalar)(-((T_Scalar)2) * znear * zfar / dz);
851 template<
typename T_Scalar>
856 if (pnear <= 0 || pfar <= 0 || pnear == pfar || left == right || top == bottom)
859 T_Scalar x = (((T_Scalar)2)*pnear) / (right-left);
860 T_Scalar y = (((T_Scalar)2)*pnear) / (top-bottom);
861 T_Scalar a = (right+left) / (right-left);
862 T_Scalar b = (top+bottom) / (top-bottom);
863 T_Scalar c = -(pfar+pnear) / (pfar-pnear);
864 T_Scalar d = -(((T_Scalar)2)*pfar*pnear) / (pfar-pnear);
866 m.
e(0,0) = x; m.
e(0,1) = 0; m.
e(0,2) = a; m.
e(0,3) = 0;
867 m.
e(1,0) = 0; m.
e(1,1) = y; m.
e(1,2) = b; m.
e(1,3) = 0;
868 m.
e(2,0) = 0; m.
e(2,1) = 0; m.
e(2,2) = c; m.
e(2,3) = d;
869 m.
e(3,0) = 0; m.
e(3,1) = 0; m.
e(3,2) = -((T_Scalar)1); m.
e(3,3) = 0;
874 template<
typename T_Scalar>
879 m.
e(0,0) = ((T_Scalar)2) / (right-left);
882 m.
e(0,3) = -(right+left) / (right-left);
885 m.
e(1,1) = ((T_Scalar)2) / (top-bottom);
887 m.
e(1,3) = -(top+bottom) / (top-bottom);
891 m.
e(2,2) = -((T_Scalar)2) / (pfar-pnear);
892 m.
e(2,3) = -(pfar+pnear) / (pfar-pnear);
897 m.
e(3,3) = ((T_Scalar)1);
902 template<
typename T_Scalar>
905 return getOrtho(left, right, bottom, top, -1, +1);
908 template<
typename T_Scalar>
913 if (degrees == 0 || (x == 0 && y ==0 && z == 0))
918 T_Scalar xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c;
920 s = (T_Scalar)
sin(degrees);
921 c = (T_Scalar)
cos(degrees);
931 out.
e(0,0) = (T_Scalar)c;
932 out.
e(1,1) = (T_Scalar)c;
935 out.
e(1,0) = -(T_Scalar)s;
936 out.
e(0,1) = (T_Scalar)s;
940 out.
e(1,0) = (T_Scalar)s;
941 out.
e(0,1) = -(T_Scalar)s;
949 out.
e(0,0) = (T_Scalar)c;
950 out.
e(2,2) = (T_Scalar)c;
953 out.
e(2,0) = (T_Scalar)s;
954 out.
e(0,2) = -(T_Scalar)s;
958 out.
e(2,0) = -(T_Scalar)s;
959 out.
e(0,2) = (T_Scalar)s;
969 out.
e(1,1) = (T_Scalar)c;
970 out.
e(2,2) = (T_Scalar)c;
973 out.
e(2,1) = -(T_Scalar)s;
974 out.
e(1,2) = (T_Scalar)s;
978 out.
e(2,1) = (T_Scalar)s;
979 out.
e(1,2) = -(T_Scalar)s;
986 T_Scalar
dot = x*x + y*y + z*z;
988 if (dot > (T_Scalar)((T_Scalar)1.0001) || dot < (T_Scalar)0.99999)
990 T_Scalar mag = (T_Scalar)
sqrt(dot);
1005 one_c = ((T_Scalar)1) - c;
1007 out.
e(0,0) = (T_Scalar)((one_c * xx) + c); out.
e(1,0) = (T_Scalar)((one_c * xy) + zs); out.
e(2,0) = (T_Scalar)((one_c * zx) - ys);
1008 out.
e(0,1) = (T_Scalar)((one_c * xy) - zs); out.
e(1,1) = (T_Scalar)((one_c * yy) + c); out.
e(2,1) = (T_Scalar)((one_c * yz) + xs);
1009 out.
e(0,2) = (T_Scalar)((one_c * zx) + ys); out.
e(1,2) = (T_Scalar)((one_c * yz) - xs); out.
e(2,2) = (T_Scalar)((one_c * zz) + c);
1013 template<
typename T_Scalar>
1016 const T_Scalar* in =
ptr();
1017 T_Scalar* out = dest.
ptr();
1029 const T_Scalar a = in[0];
const T_Scalar b = in[4];
const T_Scalar c = in[ 8];
const T_Scalar d = in[12];
1030 const T_Scalar
e = in[1];
const T_Scalar f = in[5];
const T_Scalar g = in[ 9];
const T_Scalar h = in[13];
1031 const T_Scalar i = in[2];
const T_Scalar l = in[6];
const T_Scalar m = in[10];
const T_Scalar n = in[14];
1032 const T_Scalar o = in[3];
const T_Scalar p = in[7];
const T_Scalar q = in[11];
const T_Scalar r = in[15];
1040 const T_Scalar mr = m*r;
1041 const T_Scalar gn = g*n;
1042 const T_Scalar el = e*l;
1043 const T_Scalar ip = i*p;
1044 const T_Scalar mo = m*o;
1045 const T_Scalar hl = h*l;
1046 const T_Scalar mp = m*p;
1047 const T_Scalar nq = n*q;
1048 const T_Scalar gl = g*l;
1049 const T_Scalar no = n*o;
1050 const T_Scalar gi = g*i;
1051 const T_Scalar np = n*p;
1052 const T_Scalar fi = f*i;
1053 const T_Scalar rc = r*c;
1054 const T_Scalar be = b*
e;
1055 const T_Scalar af = a*f;
1056 const T_Scalar de = d*
e;
1057 const T_Scalar df = d*f;
1058 const T_Scalar ch = c*h;
1059 const T_Scalar qh = q*h;
1064 T_Scalar Ca = +(( f*mr + gn*p + hl*q ) - ( h*mp + nq*f + r*gl ));
1069 T_Scalar Cb = -(( e*mr + gn*o + i*qh ) - ( h*mo + gi*r + nq*e ));
1074 T_Scalar Cc = +(( el*r + ip*h + f*no ) - ( hl*o + np*e + fi*r ));
1079 T_Scalar Cd = -(( el*q + f*mo + g*ip ) - ( gl*o + mp*e + q*fi ));
1081 T_Scalar det = a*Ca + b*Cb + c*Cc + d*Cd;
1090 T_Scalar Ce = -(( b*mr + c*np + d*l*q ) - ( d*mp + nq*b + rc*l ));
1095 T_Scalar Cf = +(( a*mr + c*no + d*i*q ) - ( d*mo + nq*a + rc*i ));
1100 T_Scalar Cg = -(( a*l*r + b*no + d*ip ) - ( d*l*o + np*a + r*b*i ));
1105 T_Scalar Ch = +(( a*l*q + b*mo + c*ip ) - ( c*l*o + mp*a + q*b*i ));
1111 T_Scalar Ci = +(( b*g*r + ch*p + df*q ) - ( d*g*p + q*h*b + rc*f ));
1116 T_Scalar Cl = -(( a*g*r + ch*o + de*q ) - ( d*g*o + qh*a + rc*e ));
1121 T_Scalar Cm = +(( af*r + b*h*o + de*p ) - ( df*o + h*p*a + r*be ));
1126 T_Scalar Cn = -(( af*q + b*g*o + c*e*p ) - ( c*f*o + g*p*a + q*be ));
1132 T_Scalar Co = -(( b*gn + c*hl + df*m ) - ( d*gl + h*m*b + n*c*f ));
1137 T_Scalar Cp = +(( a*gn + ch*i + de*m ) - ( d*gi + h*m*a + n*c*e ));
1142 T_Scalar Cq = -(( af*n + b*h*i + d*el ) - ( d*fi + hl*a + n*be ));
1147 T_Scalar Cr = +(( af*m + b*gi + c*el ) - ( c*fi + gl*a + m*be ));
1150 T_Scalar det2 = e*Ce + f*Cf + g*Cg + h*Ch;
1151 T_Scalar det3 = i*Ci + l*Cl + m*Cm + n*Cn;
1152 T_Scalar det4 = o*Co + p*Cp + q*Cq + r*Cr;
1153 VL_CHECK( fabs(det - det1) < 0.0001 );
1154 VL_CHECK( fabs(det - det3) < 0.0001 );
1155 VL_CHECK( fabs(det - det4) < 0.0001 );
1158 T_Scalar inv_det = 1 / det;
1160 out[0] = inv_det * Ca;
1161 out[1] = inv_det * Cb;
1162 out[2] = inv_det * Cc;
1163 out[3] = inv_det * Cd;
1164 out[4] = inv_det * Ce;
1165 out[5] = inv_det * Cf;
1166 out[6] = inv_det * Cg;
1167 out[7] = inv_det * Ch;
1168 out[8] = inv_det * Ci;
1169 out[9] = inv_det * Cl;
1170 out[10] = inv_det * Cm;
1171 out[11] = inv_det * Cn;
1172 out[12] = inv_det * Co;
1173 out[13] = inv_det * Cp;
1174 out[14] = inv_det * Cq;
1175 out[15] = inv_det * Cr;
1180 template<
typename T_Scalar>
1188 T_Scalar cosa =
dot(a,b);
1189 cosa =
clamp(cosa,-((T_Scalar)1),+((T_Scalar)1));
1193 T_Scalar alpha =
acos(cosa);
1203 template<
typename T_Scalar>
1215 kx =
clamp(kx,-((T_Scalar)1),+((T_Scalar)1));
1218 degrees_x = -degrees_x;
1221 ky =
clamp(ky,-((T_Scalar)1),+((T_Scalar)1));
1224 degrees_y = -degrees_y;
1225 if (fabs(degrees_x) > (T_Scalar)90)
1226 degrees_y = -degrees_y;
1240 #if VL_PIPELINE_PRECISION == 2
const T_Scalar & z() const
float clamp(float x, float minval, float maxval)
Matrix4 & operator-=(const Matrix4 &m)
const Vector3 & normalize(T_Scalar *len=NULL)
Matrix4 & getTransposed(Matrix4 &dest) const
Matrix4 & rotate(T_Scalar degrees, const Vector3< T_Scalar > &v)
const T_Scalar & e(int i, int j) const
const T_Scalar & x() const
Matrix4 getTransposed() const
Matrix4< unsigned int > umat4
A 4x4 matrix using unsigned int precision.
Vector3< T_Scalar > getZ() const
static Matrix4 & getTranslation(Matrix4 &out, T_Scalar x, T_Scalar y, T_Scalar z)
Matrix4 & rotateZYX(T_Scalar degZ, T_Scalar degY, T_Scalar degX)
Matrix4(T_Scalar e00, T_Scalar e01, T_Scalar e02, T_Scalar e03, T_Scalar e10, T_Scalar e11, T_Scalar e12, T_Scalar e13, T_Scalar e20, T_Scalar e21, T_Scalar e22, T_Scalar e23, T_Scalar e30, T_Scalar e31, T_Scalar e32, T_Scalar e33)
static Matrix4 getRotation(T_Scalar degrees, T_Scalar x, T_Scalar y, T_Scalar z)
Matrix4 & setT(const Vector3< T_Scalar > &v)
Matrix4 & setX(const Vector3< T_Scalar > &v)
static Matrix4 getPerspective(T_Scalar fovy, T_Scalar aspect_ratio, T_Scalar znear, T_Scalar zfar)
Matrix4 & rotate(const Vector4< T_Scalar > &from, const Vector4< T_Scalar > &to)
Matrix4< double > dmat4
A 4x4 matrix using double precision.
const T_Scalar & z() const
Matrix4 & translate(const Vector3< T_Scalar > &v)
Matrix4(const Matrix4< T > &m)
Matrix4 & translate(T_Scalar x, T_Scalar y, T_Scalar z)
Matrix4 & scale(const Vector3< T_Scalar > v)
Matrix4 operator-() const
Vector3< T_Scalar > getY() const
static Matrix4 getTranslation(T_Scalar x, T_Scalar y, T_Scalar z)
const T_Scalar & e(int i, int j) const
static Matrix4 getOrtho(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop, T_Scalar pnear, T_Scalar pfar)
Matrix4(const Matrix4 &other)
const double dRAD_TO_DEG
Constant to convert radian into degree using double precision.
The Vector4 class is a template class that implements a generic 4 components vector, see also vl::fvec4, vl::dvec4, vl::uvec4, vl::ivec4, vl::svec4, vl::usvec4, vl::bvec4, vl::ubvec4.
Matrix4 & postMultiply(const Matrix4 &m)
Matrix4 & invert(T_Scalar *determinant=NULL)
fvec3 cross(const fvec3 &v1, const fvec3 &v2)
static Matrix4 getIdentity()
Matrix4 & operator+=(T_Scalar d)
Matrix4< int > imat4
A 4x4 matrix using int precision.
Matrix4 getInverse(T_Scalar *determinant=NULL) const
Visualization Library main namespace.
Vector3< T_Scalar > getX() const
Matrix4 operator/(T_Scalar d) const
float dot(float a, float b)
const double dDEG_TO_RAD
Constant to convert degree into radian using double precision.
static Matrix4 getTranslation(const Vector3< T_Scalar > &v)
The Matrix3 class is a template class that implements a generic 3x3 matrix, see also vl::dmat3...
T_Scalar getInverse(Matrix4 &dest) const
Matrix3< T_Scalar > get3x3() const
Matrix4 operator*(T_Scalar d) const
static Matrix4 & getIdentity(Matrix4 &out)
Matrix4 & setZ(const Vector3< T_Scalar > &v)
The Vector3 class is a template class that implements a generic 3 components vector, see also vl::fvec3, vl::dvec3, vl::uvec3, vl::ivec3, vl::svec3, vl::usvec3, vl::bvec3, vl::ubvec3.
Matrix4 & operator=(const Matrix4 &m)
Matrix4 operator-(T_Scalar d) const
static Matrix4 getLookAtModeling(const Vector3< T_Scalar > &eye, const Vector3< T_Scalar > &at, const Vector3< T_Scalar > &up)
static Matrix4 getRotation(T_Scalar degrees1, const Vector3< T_Scalar > &v1, T_Scalar degrees2, const Vector3< T_Scalar > &v2, T_Scalar degrees3, const Vector3< T_Scalar > &v3)
Matrix4 & operator+=(const Matrix4 &m)
void set3x3(const Matrix3< T_Scalar > &m)
This writes only on the upper 3x3 part of the matrix without touching the last row and column...
static Matrix4 getRotation(T_Scalar degrees, const Vector3< T_Scalar > &v)
Matrix4 & fill(T_Scalar val)
static Matrix4 getRotationXYZ(T_Scalar degX, T_Scalar degY, T_Scalar degZ)
const T_Scalar & y() const
Matrix4 operator+(const Matrix4 &m) const
Matrix4 & rotate(T_Scalar degrees1, const Vector3< T_Scalar > &v1, T_Scalar degrees2, const Vector3< T_Scalar > &v2)
const T_Scalar & y() const
static Matrix4 & multiply(Matrix4 &out, const Matrix4 &p, const Matrix4 &q)
Matrix4 operator-(const Matrix4 &m) const
Matrix4 & operator/=(T_Scalar d)
Matrix4 & scale(T_Scalar x, T_Scalar y, T_Scalar z)
The Matrix4 class is a template class that implements a generic 4x4 matrix, see also vl::dmat4...
Matrix4 & fillPtr(T_Scalar *val)
const T_Scalar * ptr() const
Matrix4 & setY(const Vector3< T_Scalar > &v)
Vector4< T_Scalar > mVec[4]
void getYXRotationAngles(T_Scalar °rees_y, T_Scalar °rees_x) const
If this matrix can be represented as RY(degrees_y) * RX(degrees_x), where RX and RY are getRotation m...
static Matrix4 & getNull(Matrix4 &out)
static Matrix4 & getRotation(Matrix4 &out, T_Scalar degrees, T_Scalar x, T_Scalar y, T_Scalar z)
Matrix4 & rotate(T_Scalar degrees, T_Scalar x, T_Scalar y, T_Scalar z)
The Vector2 class is a template class that implements a generic 2 components vector, see also vl::fvec2, vl::dvec2, vl::uvec2, vl::ivec2, vl::svec2, vl::usvec2, vl::bvec2, vl::ubvec2.
Vector3< T_Scalar > getT() const
static Matrix4 getFrustum(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop, T_Scalar pnear, T_Scalar pfar)
fmat4 mat4
Defined as: 'typedef fmat4 mat4'. See also VL_PIPELINE_PRECISION.
T_Scalar diff(const Matrix4 &other) const
Matrix4 & rotate(const Vector3< T_Scalar > &from, const Vector3< T_Scalar > &to)
void getAsLookAtModeling(Vector3< T_Scalar > &eye, Vector3< T_Scalar > &at, Vector3< T_Scalar > &up, Vector3< T_Scalar > &right) const
static Matrix4 & getTranslation(Matrix4 &out, const Vector3< T_Scalar > &v)
static Matrix4 getScaling(T_Scalar x, T_Scalar y, T_Scalar z)
static Matrix4 & getScaling(Matrix4 &out, T_Scalar x, T_Scalar y, T_Scalar z)
Matrix4 & operator-=(T_Scalar d)
static Matrix4 getScaling(const Vector3< T_Scalar > &v)
static Matrix4 getOrtho2D(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop)
Matrix4 & preMultiply(const Matrix4 &m)
Matrix4 & operator*=(T_Scalar d)
static Matrix4 & getScaling(Matrix4 &out, const Vector3< T_Scalar > &v)
const T_Scalar & x() const
const T_Scalar & x() const
Matrix4 & rotateXYZ(T_Scalar degX, T_Scalar degY, T_Scalar degZ)
Matrix4< float > fmat4
A 4x4 matrix using float precision.
Matrix4 & operator*=(const Matrix4 &m)
static Matrix4 getRotation(const Vector3< T_Scalar > &from, const Vector3< T_Scalar > &to)
void getAsLookAt(Vector3< T_Scalar > &eye, Vector3< T_Scalar > &at, Vector3< T_Scalar > &up, Vector3< T_Scalar > &right) const
Matrix4 operator+(T_Scalar d) const
Matrix4 & rotate(T_Scalar degrees1, const Vector3< T_Scalar > &v1, T_Scalar degrees2, const Vector3< T_Scalar > &v2, T_Scalar degrees3, const Vector3< T_Scalar > &v3)
const T_Scalar & y() const
T_Scalar & e(int i, int j)
static Matrix4 getLookAt(const Vector3< T_Scalar > &eye, const Vector3< T_Scalar > &at, const Vector3< T_Scalar > &up)
static Matrix4 getRotation(T_Scalar degrees1, const Vector3< T_Scalar > &v1, T_Scalar degrees2, const Vector3< T_Scalar > &v2)
bool operator!=(const Matrix4 &m) const
bool operator==(const Matrix4 &m) const
static Matrix4 getRotationZYX(T_Scalar degZ, T_Scalar degY, T_Scalar degX)
const T_Scalar & w() const