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);
70 e(0,0) =
e(1,1) =
e(2,2) =
e(3,3) = n;
78 explicit Matrix4( T_Scalar e00, T_Scalar e01, T_Scalar e02, T_Scalar e03,
79 T_Scalar e10, T_Scalar e11, T_Scalar e12, T_Scalar e13,
80 T_Scalar e20, T_Scalar e21, T_Scalar e22, T_Scalar e23,
81 T_Scalar e30, T_Scalar e31, T_Scalar e32, T_Scalar e33)
83 e(0,0) = e00;
e(0,1) = e01;
e(0,2) = e02;
e(0,3) = e03;
84 e(1,0) = e10;
e(1,1) = e11;
e(1,2) = e12;
e(1,3) = e13;
85 e(2,0) = e20;
e(2,1) = e21;
e(2,2) = e22;
e(2,3) = e23;
86 e(3,0) = e30;
e(3,1) = e31;
e(3,2) = e32;
e(3,3) = e33;
91 e(0,0) =
e(1,0) =
e(2,0) =
e(3,0) =
92 e(0,1) =
e(1,1) =
e(2,1) =
e(3,1) =
93 e(0,2) =
e(1,2) =
e(2,2) =
e(3,2) =
94 e(0,3) =
e(1,3) =
e(2,3) =
e(3,3) = val;
100 memcpy(
ptr(), val,
sizeof(T_Scalar)*16);
107 for(
int i=0; i<4; ++i)
108 for(
int j=0; j<4; ++j)
109 if (
e(j,i) > other.
e(j,i))
110 err +=
e(j,i) - other.
e(j,i);
112 err += other.
e(j,i) -
e(j,i);
170 return memcmp(m.
mVec,
mVec,
sizeof(T_Scalar)*4*4) == 0;
180 memcpy(
mVec, m.
mVec,
sizeof(T_Scalar)*16);
187 for(
int i=0; i<4; ++i)
188 for(
int j=0; j<4; ++j)
189 t.
e(j,i) =
e(j,i) + m.
e(j,i);
196 for(
int i=0; i<4; ++i)
197 for(
int j=0; j<4; ++j)
205 for(
int i=0; i<4; ++i)
206 for(
int j=0; j<4; ++j)
207 t.
e(j,i) =
e(j,i) - m.
e(j,i);
214 for(
int i=0; i<4; ++i)
215 for(
int j=0; j<4; ++j)
228 for(
int i=0; i<4; ++i)
229 for(
int j=0; j<4; ++j)
237 for(
int i=0; i<4; ++i)
238 for(
int j=0; j<4; ++j)
239 t.
e(j,i) =
e(j,i) + d;
245 for(
int i=0; i<4; ++i)
246 for(
int j=0; j<4; ++j)
254 for(
int i=0; i<4; ++i)
255 for(
int j=0; j<4; ++j)
256 t.
e(j,i) =
e(j,i) - d;
262 for(
int i=0; i<4; ++i)
263 for(
int j=0; j<4; ++j)
271 for(
int i=0; i<4; ++i)
272 for(
int j=0; j<4; ++j)
273 t.
e(j,i) =
e(j,i) * d;
279 for(
int i=0; i<4; ++i)
280 for(
int j=0; j<4; ++j)
289 for(
int i=0; i<4; ++i)
290 for(
int j=0; j<4; ++j)
291 t.
e(j,i) =
e(j,i) * d;
298 for(
int i=0; i<4; ++i)
299 for(
int j=0; j<4; ++j)
307 return memcmp(
ptr(), i.
ptr(),
sizeof(T_Scalar)*16) == 0;
326 t.
e(0,0) =
e(0,0); t.
e(1,0) =
e(1,0); t.
e(2,0) =
e(2,0);
327 t.
e(0,1) =
e(0,1); t.
e(1,1) =
e(1,1); t.
e(2,1) =
e(2,1);
328 t.
e(0,2) =
e(0,2); t.
e(1,2) =
e(1,2); t.
e(2,2) =
e(2,2);
335 e(0,0) = m.
e(0,0);
e(1,0) = m.
e(1,0);
e(2,0) = m.
e(2,0);
336 e(0,1) = m.
e(0,1);
e(1,1) = m.
e(1,1);
e(2,1) = m.
e(2,1);
337 e(0,2) = m.
e(0,2);
e(1,2) = m.
e(1,2);
e(2,2) = m.
e(2,2);
345 const T_Scalar*
ptr()
const 353 for(
int i=0; i<4; ++i)
354 for(
int j=i; j<4; ++j)
366 for(
int i=0; i<4; ++i)
367 for(
int j=0; j<4; ++j)
374 for(
int i=0; i<4; ++i)
375 for(
int j=0; j<4; ++j)
376 dest.
e(j,i) =
e(i,j);
382 for(
int i=0; i<4; ++i)
383 for(
int j=0; j<4; ++j)
408 static const T_Scalar I4d[] =
410 (T_Scalar)1, (T_Scalar)0, (T_Scalar)0, (T_Scalar)0,
411 (T_Scalar)0, (T_Scalar)1, (T_Scalar)0, (T_Scalar)0,
412 (T_Scalar)0, (T_Scalar)0, (T_Scalar)1, (T_Scalar)0,
413 (T_Scalar)0, (T_Scalar)0, (T_Scalar)0, (T_Scalar)1
415 memcpy(
mVec, I4d,
sizeof(T_Scalar)*16);
451 static Matrix4 getFrustum(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop, T_Scalar pnear, T_Scalar pfar);
453 static Matrix4 getOrtho(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop, T_Scalar pnear, T_Scalar pfar);
455 static Matrix4 getOrtho2D(T_Scalar pleft, T_Scalar pright, T_Scalar pbottom, T_Scalar ptop);
492 return rotate(degrees, v.
x(), v.
y(), v.
z());
624 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);
625 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);
626 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);
627 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);
629 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);
630 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);
631 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);
632 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);
634 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);
635 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);
636 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);
637 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);
639 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);
640 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);
641 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);
642 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);
650 return *
this =
multiply(t, *
this, m);
656 return *
this =
multiply(t, m, *
this);
660 const T_Scalar&
e(
int i,
int j)
const {
return mVec[j][i]; }
661 T_Scalar&
e(
int i,
int j) {
return mVec[j][i]; }
673 template<
typename T_Scalar>
681 template<
typename T_Scalar>
687 template<
typename T_Scalar>
694 template<
typename T_Scalar>
698 v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) + v.
z()*m.
e(0,2) + v.
w()*m.
e(0,3),
699 v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) + v.
z()*m.
e(1,2) + v.
w()*m.
e(1,3),
700 v.
x()*m.
e(2,0) + v.
y()*m.
e(2,1) + v.
z()*m.
e(2,2) + v.
w()*m.
e(2,3),
701 v.
x()*m.
e(3,0) + v.
y()*m.
e(3,1) + v.
z()*m.
e(3,2) + v.
w()*m.
e(3,3)
707 template<
typename T_Scalar>
711 v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) + v.
z()*m.
e(0,2) + m.
e(0,3),
712 v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) + v.
z()*m.
e(1,2) + m.
e(1,3),
713 v.
x()*m.
e(2,0) + v.
y()*m.
e(2,1) + v.
z()*m.
e(2,2) + m.
e(2,3)
719 template<
typename T_Scalar>
723 v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) + m.
e(0,3),
724 v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) + m.
e(1,3)
729 template<
typename T_Scalar>
733 v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) + v.
z()*m.
e(2,0) + v.
w()*m.
e(3,0),
734 v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) + v.
z()*m.
e(2,1) + v.
w()*m.
e(3,1),
735 v.
x()*m.
e(0,2) + v.
y()*m.
e(1,2) + v.
z()*m.
e(2,2) + v.
w()*m.
e(3,2),
736 v.
x()*m.
e(0,3) + v.
y()*m.
e(1,3) + v.
z()*m.
e(2,3) + v.
w()*m.
e(3,3)
742 template<
typename T_Scalar>
746 v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) + v.
z()*m.
e(2,0) + m.
e(3,0),
747 v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) + v.
z()*m.
e(2,1) + m.
e(3,1),
748 v.
x()*m.
e(0,2) + v.
y()*m.
e(1,2) + v.
z()*m.
e(2,2) + m.
e(3,2)
754 template<
typename T_Scalar>
758 v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) + m.
e(3,0),
759 v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) + m.
e(3,1)
763 template<
typename T_Scalar>
771 T_Scalar la_modeling[] =
773 xaxis.
x() , xaxis.
y() , xaxis.
z() , 0,
774 yaxis.
x() , yaxis.
y() , yaxis.
z() , 0,
775 zaxis.
x() , zaxis.
y() , zaxis.
z() , 0,
776 eye.
x() , eye.
y() , eye.
z() , 1
782 template<
typename T_Scalar>
792 xaxis.
x() , yaxis.
x() , zaxis.
x() , 0,
793 xaxis.
y() , yaxis.
y() , zaxis.
y() , 0,
794 xaxis.
z() , yaxis.
z() , zaxis.
z() , 0,
795 -
dot(xaxis,eye), -
dot(yaxis,eye), -
dot(zaxis,eye), 1
801 template<
typename T_Scalar>
816 template<
typename T_Scalar>
824 template<
typename T_Scalar>
829 T_Scalar rads = (fovy / ((T_Scalar)2)) * (T_Scalar)
dDEG_TO_RAD;
830 T_Scalar dz = zfar - znear;
831 T_Scalar sa =
sin(rads);
832 if ((dz == 0) || (sa == 0) || (aspect_ratio == 0))
834 T_Scalar ctan =
cos(rads) / sa;
836 m.
e(0,0) = (T_Scalar)(ctan / aspect_ratio);
837 m.
e(1,1) = (T_Scalar)(ctan);
838 m.
e(2,2) = (T_Scalar)(-(zfar + znear) / dz);
839 m.
e(3,2) = -((T_Scalar)1);
840 m.
e(2,3) = (T_Scalar)(-((T_Scalar)2) * znear * zfar / dz);
846 template<
typename T_Scalar>
851 if (pnear <= 0 || pfar <= 0 || pnear == pfar || left == right || top == bottom)
854 T_Scalar x = (((T_Scalar)2)*pnear) / (right-left);
855 T_Scalar y = (((T_Scalar)2)*pnear) / (top-bottom);
856 T_Scalar a = (right+left) / (right-left);
857 T_Scalar b = (top+bottom) / (top-bottom);
858 T_Scalar c = -(pfar+pnear) / (pfar-pnear);
859 T_Scalar d = -(((T_Scalar)2)*pfar*pnear) / (pfar-pnear);
861 m.
e(0,0) = x; m.
e(0,1) = 0; m.
e(0,2) = a; m.
e(0,3) = 0;
862 m.
e(1,0) = 0; m.
e(1,1) = y; m.
e(1,2) = b; m.
e(1,3) = 0;
863 m.
e(2,0) = 0; m.
e(2,1) = 0; m.
e(2,2) = c; m.
e(2,3) = d;
864 m.
e(3,0) = 0; m.
e(3,1) = 0; m.
e(3,2) = -((T_Scalar)1); m.
e(3,3) = 0;
869 template<
typename T_Scalar>
874 m.
e(0,0) = ((T_Scalar)2) / (right-left);
877 m.
e(0,3) = -(right+left) / (right-left);
880 m.
e(1,1) = ((T_Scalar)2) / (top-bottom);
882 m.
e(1,3) = -(top+bottom) / (top-bottom);
886 m.
e(2,2) = -((T_Scalar)2) / (pfar-pnear);
887 m.
e(2,3) = -(pfar+pnear) / (pfar-pnear);
892 m.
e(3,3) = ((T_Scalar)1);
897 template<
typename T_Scalar>
900 return getOrtho(left, right, bottom, top, -1, +1);
903 template<
typename T_Scalar>
908 if (degrees == 0 || (x == 0 && y ==0 && z == 0))
913 T_Scalar xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c;
915 s = (T_Scalar)
sin(degrees);
916 c = (T_Scalar)
cos(degrees);
926 out.
e(0,0) = (T_Scalar)c;
927 out.
e(1,1) = (T_Scalar)c;
930 out.
e(1,0) = -(T_Scalar)s;
931 out.
e(0,1) = (T_Scalar)s;
935 out.
e(1,0) = (T_Scalar)s;
936 out.
e(0,1) = -(T_Scalar)s;
944 out.
e(0,0) = (T_Scalar)c;
945 out.
e(2,2) = (T_Scalar)c;
948 out.
e(2,0) = (T_Scalar)s;
949 out.
e(0,2) = -(T_Scalar)s;
953 out.
e(2,0) = -(T_Scalar)s;
954 out.
e(0,2) = (T_Scalar)s;
964 out.
e(1,1) = (T_Scalar)c;
965 out.
e(2,2) = (T_Scalar)c;
968 out.
e(2,1) = -(T_Scalar)s;
969 out.
e(1,2) = (T_Scalar)s;
973 out.
e(2,1) = (T_Scalar)s;
974 out.
e(1,2) = -(T_Scalar)s;
981 T_Scalar
dot = x*x + y*y + z*z;
983 if (dot > (T_Scalar)((T_Scalar)1.0001) || dot < (T_Scalar)0.99999)
985 T_Scalar mag = (T_Scalar)
sqrt(dot);
1000 one_c = ((T_Scalar)1) - c;
1002 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);
1003 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);
1004 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);
1008 template<
typename T_Scalar>
1011 const T_Scalar* in =
ptr();
1012 T_Scalar* out = dest.
ptr();
1024 const T_Scalar a = in[0];
const T_Scalar b = in[4];
const T_Scalar c = in[ 8];
const T_Scalar d = in[12];
1025 const T_Scalar
e = in[1];
const T_Scalar f = in[5];
const T_Scalar g = in[ 9];
const T_Scalar h = in[13];
1026 const T_Scalar i = in[2];
const T_Scalar l = in[6];
const T_Scalar m = in[10];
const T_Scalar n = in[14];
1027 const T_Scalar o = in[3];
const T_Scalar p = in[7];
const T_Scalar q = in[11];
const T_Scalar r = in[15];
1035 const T_Scalar mr = m*r;
1036 const T_Scalar gn = g*n;
1037 const T_Scalar el = e*l;
1038 const T_Scalar ip = i*p;
1039 const T_Scalar mo = m*o;
1040 const T_Scalar hl = h*l;
1041 const T_Scalar mp = m*p;
1042 const T_Scalar nq = n*q;
1043 const T_Scalar gl = g*l;
1044 const T_Scalar no = n*o;
1045 const T_Scalar gi = g*i;
1046 const T_Scalar np = n*p;
1047 const T_Scalar fi = f*i;
1048 const T_Scalar rc = r*c;
1049 const T_Scalar be = b*
e;
1050 const T_Scalar af = a*f;
1051 const T_Scalar de = d*
e;
1052 const T_Scalar df = d*f;
1053 const T_Scalar ch = c*h;
1054 const T_Scalar qh = q*h;
1059 T_Scalar Ca = +(( f*mr + gn*p + hl*q ) - ( h*mp + nq*f + r*gl ));
1064 T_Scalar Cb = -(( e*mr + gn*o + i*qh ) - ( h*mo + gi*r + nq*e ));
1069 T_Scalar Cc = +(( el*r + ip*h + f*no ) - ( hl*o + np*e + fi*r ));
1074 T_Scalar Cd = -(( el*q + f*mo + g*ip ) - ( gl*o + mp*e + q*fi ));
1076 T_Scalar det = a*Ca + b*Cb + c*Cc + d*Cd;
1085 T_Scalar Ce = -(( b*mr + c*np + d*l*q ) - ( d*mp + nq*b + rc*l ));
1090 T_Scalar Cf = +(( a*mr + c*no + d*i*q ) - ( d*mo + nq*a + rc*i ));
1095 T_Scalar Cg = -(( a*l*r + b*no + d*ip ) - ( d*l*o + np*a + r*b*i ));
1100 T_Scalar Ch = +(( a*l*q + b*mo + c*ip ) - ( c*l*o + mp*a + q*b*i ));
1106 T_Scalar Ci = +(( b*g*r + ch*p + df*q ) - ( d*g*p + q*h*b + rc*f ));
1111 T_Scalar Cl = -(( a*g*r + ch*o + de*q ) - ( d*g*o + qh*a + rc*e ));
1116 T_Scalar Cm = +(( af*r + b*h*o + de*p ) - ( df*o + h*p*a + r*be ));
1121 T_Scalar Cn = -(( af*q + b*g*o + c*e*p ) - ( c*f*o + g*p*a + q*be ));
1127 T_Scalar Co = -(( b*gn + c*hl + df*m ) - ( d*gl + h*m*b + n*c*f ));
1132 T_Scalar Cp = +(( a*gn + ch*i + de*m ) - ( d*gi + h*m*a + n*c*e ));
1137 T_Scalar Cq = -(( af*n + b*h*i + d*el ) - ( d*fi + hl*a + n*be ));
1142 T_Scalar Cr = +(( af*m + b*gi + c*el ) - ( c*fi + gl*a + m*be ));
1145 T_Scalar det2 = e*Ce + f*Cf + g*Cg + h*Ch;
1146 T_Scalar det3 = i*Ci + l*Cl + m*Cm + n*Cn;
1147 T_Scalar det4 = o*Co + p*Cp + q*Cq + r*Cr;
1148 VL_CHECK( fabs(det - det1) < 0.0001 );
1149 VL_CHECK( fabs(det - det3) < 0.0001 );
1150 VL_CHECK( fabs(det - det4) < 0.0001 );
1153 T_Scalar inv_det = 1 / det;
1155 out[0] = inv_det * Ca;
1156 out[1] = inv_det * Cb;
1157 out[2] = inv_det * Cc;
1158 out[3] = inv_det * Cd;
1159 out[4] = inv_det * Ce;
1160 out[5] = inv_det * Cf;
1161 out[6] = inv_det * Cg;
1162 out[7] = inv_det * Ch;
1163 out[8] = inv_det * Ci;
1164 out[9] = inv_det * Cl;
1165 out[10] = inv_det * Cm;
1166 out[11] = inv_det * Cn;
1167 out[12] = inv_det * Co;
1168 out[13] = inv_det * Cp;
1169 out[14] = inv_det * Cq;
1170 out[15] = inv_det * Cr;
1175 template<
typename T_Scalar>
1183 T_Scalar cosa =
dot(a,b);
1184 cosa =
clamp(cosa,-((T_Scalar)1),+((T_Scalar)1));
1188 T_Scalar alpha =
acos(cosa);
1198 template<
typename T_Scalar>
1210 kx =
clamp(kx,-((T_Scalar)1),+((T_Scalar)1));
1213 degrees_x = -degrees_x;
1216 ky =
clamp(ky,-((T_Scalar)1),+((T_Scalar)1));
1219 degrees_y = -degrees_y;
1220 if (fabs(degrees_x) > (T_Scalar)90)
1221 degrees_y = -degrees_y;
1235 #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)
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