DEMO.DESIGN
Frequently Asked Questions
 
оглавление | demo party в ex-СССР | infused bytes e-mag | новости от ib/news | другие проекты | письмо | win koi lat

следующий фpагмент (2)
- [56] Available echoes... (2:5030/84) ------------------------- RU.ALGORITHMS - Msg : 1 of 2 From : Alex Tutubalin 2:5020/96 06 May 96 10:19:00 To : Mike Peleah Subj : Определитель матрицы -------------------------------------------------------------------------------- Dear Mike! MP>>> Подскажите плииз как наиболее бысто вычислить определитель MP>>> матрицы ? AT>> Это смотpя какая матpица. Методов _много_ и каждый из них имеет свои AT>> достоинства-недостатки. MP> Матрица квадратная. Если матpица квадpатная (не ленточная, не тpеугольная на итп) и не слишком pазpеженная, то самыми pаспpостpаненными _точными_ (есть еще и пpиблиденные) методами являются метод Гаусса и метод квадpатных коpней. Описание есть в любом спpавочнике. Впpочем, кусок кода, котоpый pеализует метод Гаусса (выдpано из матpичного класса, котоpый я писал лет 7-8 назад, это один из моих пеpвых опытов в C++): В этом коде функция matrix.Get(i,j) возвpащает элемент matrix[i][j], а matrix.Set(i,j,val) аналогична matrix[i][j]=val. Hу не умел я тогда пеpеопpеделять опеpатоpы :). EPSYLON - это близкое к нулю число, если fabs(a)<EPSYLON, то a считается нулем :) double Matrix::Det ( void ) const { if( Rows != Columns ) return 0. ; Matrix a ( *this ); unsigned *z = new unsigned [Rows ]; double *b=new double [Rows ], *c= new double [Rows ]; unsigned i ,j ,k ,p; double y , w, det=1.; for( i = 0; i < Rows ; i++) z[i] = i; for ( i=0; i<Rows;i++) // Outer cycle { k=i; p=i+1; y=a.Get(i,i); for( j = p; j < Rows ; j++) { w=a.Get(i,j); if ( fabs (w) >fabs (y) ){ y=w; k=j; } } if ( fabs (y) < EPSYLON ) { delete c; delete b; delete z; return (0,0); } det*=y; if(k!=i) det=-det; y=1./y; for ( j=0;j<Rows;j++) { c[j]=a.Get(j,k); a.Set(j,k,a.Get(j,i)); a.Set( j , i ,-c[j]*y); b[j]=a.Get(i,j)*y; a.Set(i,j,b[j]); } j=z[i]; z[i]=z[k]; z[k]=j; a.Set(i,i,y); for (k = 0; k < Rows ; k++) if(k != i) for( j = 0 ;j < Rows ;j++) if(j != i) a.Set( k, j, a.Get( k, j) - b[j] * c[k] ); } // End of Outer Cycle delete(b); delete(c); delete(z); return(det); } С уважением,Alex Tutubalin --- GoldED 2.42.G1114+ * Origin: Ваша киска купила бы Cisco (2:5020/96)
следующий фpагмент (3)|пpедыдущий фpагмент (1)
EM>>> Подкиньте алгоpитм, пpиводящий матpицy к стyпенчатомy видy. === Cut === maxnumber - максимальный pазмеp матpицы обpабатываемый пpогpаммой number - pазмеp котоpый сейчас обpабатывается я занаю что извpат но писалось в институт а там все pавно оценить не могут :) const maxnumber = 100; number : byte = 0; type resulttype = array[1..maxnumber] of real; matrixtype = array[1..maxnumber] of resulttype; function gauss(a:matrixtype;b:resulttype;var x:resulttype):boolean; var i,h,j : integer; tmpa : resulttype; tmpb,r : real; begin gauss:=false; for i:=1 to number-1 do begin if a[i,i]=0 then begin h:=i+1; while (a[h,i]=0) and (h<=number) do inc(h); if h>number then exit; tmpa:=a[h]; a[h]:=a[i]; a[i]:=tmpa; tmpb:=b[h]; b[h]:=b[i]; b[i]:=tmpb; end; for h:=i+1 to number do begin r:=-a[h,i]/a[i,i]; for j:=1 to number do a[h,j]:=a[h,j]+r*a[i,j]; b[h]:=b[h]+r*b[i]; end; end; if a[number,number]=0 then exit; x[number]:=b[number]/a[number,number]; for i:=number-1 downto 1 do begin r:=0; for h:=i+1 to number do r:=r+a[i,h]*x[h]; x[i]:=(b[i]-r)/a[i][i]; end; gauss:=true; end; === Cut ===
следующий фpагмент (4)|пpедыдущий фpагмент (2)
- Usenet echoes (21:200/1) -------------------------- COMP.GRAPHICS.ALGORITHMS - Msg : 49 of 121 From : gmt@aviator.cis.ufl.edu 2:5030/144.99 21 May 94 20:44:04 To : All 27 May 94 00:31:26 Subj : Re: Request: Inverse of a 4x4 matrix algorithm -------------------------------------------------------------------------------- In article <2rft8r$p4k@cc.tut.fi> frank@helium.ee.tut.fi (Cameron Frank) writes: Mike Matsel (matsel@cs.uoregon.edu) wrote: : : Does anyone have C code, or at least some psuedo-code for the finding the : inverse of a 4 x 4 matrix? Its for a ray tracer. Thanks! In a lot of cases in graphics, you will be strictly dealing with affine transforms. (My cheesy non-definition of affine is that you are only dealing with translations, rotations, and scaling. . .no shearing or perspective projection.) If this is the case, then you can use the following to find the inverse: ---------------------------------------------------------------------- // (Note that a Matrix is: // typedef float Matrix[4][4]; // // Generally speaking, a matrix doesn't need to be bigger than 4x3, but // since this code is to work with GL and it uses 4x4 matrices. . . // Find the inverse of a matrix that is made up of only scales, rotations, // and translations. void MatrixAffineInverse( Matrix m, Matrix result ) { float Tx, Ty, Tz; // The rotational part of the matrix is simply the transpose of the // original matrix. result[0][0] = m[0][0]; result[1][0] = m[0][1]; result[2][0] = m[0][2]; result[0][1] = m[1][0]; result[1][1] = m[1][1]; result[2][1] = m[1][2]; result[0][2] = m[2][0]; result[1][2] = m[2][1]; result[2][2] = m[2][2]; // The right column vector of the matrix should always be [ 0 0 0 1 ] // In most cases. . . you don't need this column at all because it'll // never be used in the program, but since this code is used with GL // and it does consider this column, it is here. result[0][3] = result[1][3] = result[2][3] = 0; result[3][3] = 1; // The translation components of the original matrix. Tx = m[3][0]; Ty = m[3][1]; Tz = m[3][2]; // Rresult = -(Tm * Rm) to get the translation part of the inverse result[3][0] = -( m[0][0] * Tx + m[0][1] * Ty + m[0][2] * Tz ); result[3][1] = -( m[1][0] * Tx + m[1][1] * Ty + m[1][2] * Tz ); result[3][2] = -( m[2][0] * Tx + m[2][1] * Ty + m[2][2] * Tz ); }
следующий фpагмент (5)|пpедыдущий фpагмент (3)
- Usenet echoes (21:200/1) -------------------------- COMP.GRAPHICS.ALGORITHMS - Msg : 52 of 116 From : rcskb@minyos.xx.rmit.EDU.AU 2:5030/144.99 23 May 94 03:01:50 To : All 27 May 94 01:18:18 Subj : (1) Another one: Inverse of a 4x4 matrix algorithm -------------------------------------------------------------------------------- hbaker@netcom.com (Henry G. Baker) writes: >The following algorithm fails if a pivot element ==0.0. Just for the hell of it, here is my 4x4 matrix inversion code. It is C++ code and based on some code I found in Graphics Gems ??. Also not that the code is also complicated by the need to be able to work with fixed point values (inversion is done in floating point however). It works well for me, but your mileage may vary. //--------------------------------------------------------------------------- // Utility routines to compute the inverse of a matrix. These routines // simply cannot be done in fixed point, for lack of range. Thus they // will be slow on machines with not co-processor. //--------------------------------------------------------------------------- inline float det2x2(float a,float b, float c,float d) /**************************************************************************** * * Function: det2x2 * Parameters: a,b - First row of matrix * c,d - Second row of matrix * Returns: Deteminent for a 2x2 matrix. * ****************************************************************************/ { return a * d - b * c; } float det3x3(float a1,float a2,float a3, float b1,float b2,float b3, float c1,float c2,float c3) /**************************************************************************** * * Function: det3x3 * Parameters: a1,a2,a3 - First row in matrix * b1,b2,b3 - Second row in matrix * c1,c2,c3 - Third row in matrix * Returns: Determinent for 3x3 matrix. * ****************************************************************************/ { float ans; ans = a1 * det2x2( b2, b3, c2, c3) - b1 * det2x2( a2, a3, c2, c3) + c1 * det2x2( a2, a3, b2, b3); return ans; } float det4x4(Mat4x4& m) /**************************************************************************** * * Function: det4x4 * Parameters: m - Matrix to compute determinent for * Returns: Determinent for 4x4 matrix. * ****************************************************************************/ { float a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4,d1,d2,d3,d4; // Assign to individual variable names to aid // selecting correct values a1 = realToFlt(m(0,0)); b1 = realToFlt(m(0,1)); c1 = realToFlt(m(0,2)); d1 = realToFlt(m(0,3)); a2 = realToFlt(m(1,0)); b2 = realToFlt(m(1,1)); c2 = realToFlt(m(1,2)); d2 = realToFlt(m(1,3)); a3 = realToFlt(m(2,0)); b3 = realToFlt(m(2,1)); c3 = realToFlt(m(2,2)); d3 = realToFlt(m(2,3)); a4 = realToFlt(m(3,0)); b4 = realToFlt(m(3,1)); c4 = realToFlt(m(3,2)); d4 = realToFlt(m(3,3)); return a1 * det3x3( b2, b3, b4, c2, c3, c4, d2, d3, d4) - b1 * det3x3( a2, a3, a4, c2, c3, c4, d2, d3, d4) + c1 * det3x3( a2, a3, a4, b2, b3, b4, d2, d3, d4) - d1 * det3x3( a2, a3, a4, b2, b3, b4, c2, c3, c4); } void adjoint(float adj[4][4],Mat4x4& m) /****************************************************************************
следующий фpагмент (6)|пpедыдущий фpагмент (4)
- Usenet echoes (21:200/1) -------------------------- COMP.GRAPHICS.ALGORITHMS - Msg : 53 of 116 From : rcskb@minyos.xx.rmit.EDU.AU 2:5030/144.99 23 May 94 03:01:50 To : All 27 May 94 01:18:18 Subj : (2) Another one: Inverse of a 4x4 matrix algorithm -------------------------------------------------------------------------------- X-RealName: Kendall Bennett * * Function: adjoint * Parameters: adj - Place to store the adjoint matrix * m - Matrix to compute adjoint for * * Description: Calculates the adjoint of a 4x4 matrix. * * Let a denote the minor determinent of matrix A obtained by * ij * deleting the ith row and the jth column from A. * i+j * Let b = (-1) a * ij ji * * The matrix B = (b ) is the adjoint of A * ij * ****************************************************************************/ { float a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4,d1,d2,d3,d4; // Assign to individual variable names to aid // selecting correct values a1 = realToFlt(m(0,0)); b1 = realToFlt(m(0,1)); c1 = realToFlt(m(0,2)); d1 = realToFlt(m(0,3)); a2 = realToFlt(m(1,0)); b2 = realToFlt(m(1,1)); c2 = realToFlt(m(1,2)); d2 = realToFlt(m(1,3)); a3 = realToFlt(m(2,0)); b3 = realToFlt(m(2,1)); c3 = realToFlt(m(2,2)); d3 = realToFlt(m(2,3)); a4 = realToFlt(m(3,0)); b4 = realToFlt(m(3,1)); c4 = realToFlt(m(3,2)); d4 = realToFlt(m(3,3)); // Compute the output matrix. Note that the row & column labeling // is reversed since we transpose rows & columns for the adjoint // matrix. adj[0][0] = det3x3( b2, b3, b4, c2, c3, c4, d2, d3, d4); adj[1][0] = - det3x3( a2, a3, a4, c2, c3, c4, d2, d3, d4); adj[2][0] = det3x3( a2, a3, a4, b2, b3, b4, d2, d3, d4); adj[3][0] = - det3x3( a2, a3, a4, b2, b3, b4, c2, c3, c4); adj[0][1] = - det3x3( b1, b3, b4, c1, c3, c4, d1, d3, d4); adj[1][1] = det3x3( a1, a3, a4, c1, c3, c4, d1, d3, d4); adj[2][1] = - det3x3( a1, a3, a4, b1, b3, b4, d1, d3, d4); adj[3][1] = det3x3( a1, a3, a4, b1, b3, b4, c1, c3, c4); adj[0][2] = det3x3( b1, b2, b4, c1, c2, c4, d1, d2, d4); adj[1][2] = - det3x3( a1, a2, a4, c1, c2, c4, d1, d2, d4); adj[2][2] = det3x3( a1, a2, a4, b1, b2, b4, d1, d2, d4); adj[3][2] = - det3x3( a1, a2, a4, b1, b2, b4, c1, c2, c4); adj[0][3] = - det3x3( b1, b2, b3, c1, c2, c3, d1, d2, d3); adj[1][3] = det3x3( a1, a2, a3, c1, c2, c3, d1, d2, d3); adj[2][3] = - det3x3( a1, a2, a3, b1, b2, b3, d1, d2, d3); adj[3][3] = det3x3( a1, a2, a3, b1, b2, b3, c1, c2, c3); } Mat4x4& Mat4x4::inverse(void) /**************************************************************************** * * Function: Mat4x4::inverse * * Description: Computes the inverse of the 4x4 matrix, and returns a * reference to it. We calculate this with the following * formula: * -1 * A = ___1___ adjoint A * det A * * If the original matrix was special, the inverse will be * special also. * ****************************************************************************/ { float adj[4][4]; adjoint(adj,*this); // Compute the adjoint of the matrix /* Calculate the 4x4 determinent. If this is zero, the matrix has * no inverse, so we set it to an identity matrix (what a kludge). */ float det = det4x4(*this); if (ABS(det) < 1e-8) return this->identity(); else { /* Scale the adjoint matrix to get the inverse */ det = 1 / det; for (int i = 0; i < 4-special; i++) for (int j = 0; j < 4; j++) (*this)(i,j) = fltToReal(adj[i][j] * det); return *this; } }
следующий фpагмент (7)|пpедыдущий фpагмент (5)
- Usenet echoes (21:200/1) -------------------------- COMP.GRAPHICS.ALGORITHMS - Msg : 22 of 34 From : deimos@sans.vuw.ac.nz 2:5030/315 12 Feb 96 12:29:16 To : All 14 Feb 96 01:57:34 Subj : Re: Matrix Inverse? -------------------------------------------------------------------------------- Illusion/Phoenix (d94marka@isy.liu.se) wrote: : Justin R Kidder <jkidder> wrote: : >Hello everyone, : > : > I am working on some code to do a snakes-based image segmentation, and I : > was wondering if anyone could send me a function to find the inverse of a : > matrix. There is no point in reinventing the wheel, right? Thanks. if it's only 3*3 matricies that you're wanting to invert, then here's the relevant pieces of c++ code from my own 3space library, if you're interested in the whole thing, or an explanation of the mathematics behind it, E-Mail me (deimos@sans.vuw.ac.nz) and I'll send it on to you. if it's going to be larger matricies (such as 4*4 if you're doing some 4D work) then the code should be fairly easy to extrapolate into a higher dimension. As for generalising it to handle matricies of any size, then you're on your own. // FROM 3SPACE.H class matrix { private: float X[3][3]; friend float __det2X2(matrix, int, int); public: // [snip] friend float determinant (matrix); friend matrix transpose (matrix); friend matrix inverse (matrix); }; // FROM 3SPACE.CPP float __det2X2 (matrix M, int row, int col) { float Det[4]; int cursor = 0; for (int r=0;r<3;r++) for (int c=0;c<3;c++) if (r != row && c != col) Det[cursor++] = M.X[r][c]; return Det[0] * Det[3] - Det[1] * Det[2]; } float determinant (matrix M) { float DetM; DetM = M.X[0][0]*M.X[1][1]*M.X[2][2]+M.X[0][1]*M.X[1][2]*M.X[2][0] +M.X[0][2]*M.X[1][0]*M.X[2][1]-M.X[0][0]*M.X[1][2]*M.X[2][1] -M.X[0][2]*M.X[1][1]*M.X[2][0]-M.X[0][1]*M.X[1][0]*M.X[2][2]; return DetM; } matrix transpose (matrix M) { float temp; matrix N = M; for (int i=0;i<3;i++) for (int c=i;c<3;c++) { temp = N.X[i][c]; N.X[i][c] = N.X[c][i]; N.X[c][i] = temp; } return N; } matrix inverse (matrix M) { if (determinant(M) == 0) // if the matrix is not invertible return matrix(0, 0, 0, 0, 0, 0, 0, 0, 0); else { float DetM = determinant(M); matrix N; for (int r=0;r<3;r++) for (int c=0;c<3;c++) N.X[r][c] = (pow(-1, r+c) * __det2X2(M, r, c)) / DetM; N = transpose(N); return N; } }
следующий фpагмент (8)|пpедыдущий фpагмент (6)
- Usenet echoes (21:200/1) -------------------------- COMP.GRAPHICS.ALGORITHMS - Msg : 35 of 93 From : roddi@cs.monash.edu.au 2:5030/144.99 23 Aug 94 11:26:12 To : All 27 Sep 93 03:16:44 Subj : (1) Re: Matrix Inverse algorithm anyone? -------------------------------------------------------------------------------- >Does anyone have a matrix inverse algorithm, specifically for a 4 by 4 >matrix, any C code would be greatly appreciated, thanks! This one's in C++, but being based on an algorith from _Numerical Recipes in C_, it is VERY close to plain C. It uses Gauss-Jordan elimination with full pivoting. matrix matrix::i(void) // RETURNS: the matrice's inverse, assuming one exists. // // NOTES: the inverse is calculated using Gauss-Jordan elimination with // full pivoting. Based on the algorithm presented in // "Numerical Recipes in C", 2nd edn, Press et al. pp 39-40. // // CLASS VARS CHANGED: none // PARAMETERS CHANGED: none // GLOBALS CHANGED: none // LAST MODIFIED: 25/7/94 { double big, fabval, pivinv, temp; int i, j, k, l, ll, irow, icol, n; int *indxc, *indxr, *ipiv; matrix res(*this); // make sure matrix is square assertion(rows == cols); n = rows; indxc = new int[n]; assert(indxc != 0); indxr = new int[n]; assert(indxr != 0); ipiv = new int[n]; assert(ipiv != 0); for (j=0; j<n; j++) ipiv[j] = 0; for (i=0; i<n; i++) { big = 0.0; for (j=0; j<n; j++) if (ipiv[j] != 1) for (k=0; k<n; k++) { if (ipiv[k] == 0) { if (res.e[j][k] < 0) fabval = -res.e[j][k]; else fabval = res.e[j][k]; if (fabval >= big) { big = fabval; irow = j; icol = k; } } else { if (ipiv[k] > 1) debug::fatalError("Singular matrix in matrix::operator !"); } } (ipiv[icol])++; if (irow != icol) for (l=0; l<n; l++) { temp = res.e[irow][l]; res.e[irow][l] = res.e[icol][l]; res.e[icol][l] = temp; } indxr[i] = irow; indxc[i] = icol; if (res.e[icol][icol] == 0.0) debug::fatalError("Singular matrix in matrix::operator !"); pivinv = 1.0/res.e[icol][icol]; res.e[icol][icol] = 1.0; for (l=0; l<n; l++) res.e[icol][l] *= pivinv; for (ll=0; ll<n; ll++) if (ll != icol) { temp = res.e[ll][icol]; res.e[ll][icol] = 0.0; for (l=0; l<n; l++) res.e[ll][l] -= res.e[icol][l]*temp; } } for (l=n-1; l>=0; l--) { if (indxr[l] != indxc[l]) for (k=0; k<n; k++) { temp = res.e[k][indxr[l]]; res.e[k][indxr[l]] = res.e[k][indxc[l]]; res.e[k][indxc[l]] = temp; } } delete [] ipiv; delete [] indxr; delete [] indxc; return res; } All you really need to know is that the line matrix res(*this); creates a matrix called res initialised to the matrix you want to take the inverse of. The C equivalent of the matrix class is: typedef struct matrix { int rows; int cols; double e[MAXSIZE][MAXSIZE]; } Hope this helps. Roddi
следующий фpагмент (9)|пpедыдущий фpагмент (7)
- Usenet echoes (21:200/1) -------------------------- COMP.GRAPHICS.ALGORITHMS - Msg : 22 of 25 From : shirley@cs.indiana.edu 2:5030/144.99 17 May 94 01:42:30 To : All 22 May 94 03:27:48 Subj : (1) Re: Request: Inverse of a 4x4 matrix algorithm -------------------------------------------------------------------------------- > Does anyone have C code, or at least some psuedo-code for the finding the > inverse of a 4 x 4 matrix? Its for a ray tracer. Thanks! > Note that the transpose is not enough in this situation. some code written by Greg Vogl in one of my classes: double d = determinant(); // put big calculation here: 18 e components for each of 16 m.e components! // To save time, Maple was used to do the calculation // copy and paste was used to get the numbers from Maple // search and replace was used to format from Maple output into C++ code double a1 = e[1][2], a2 = e[0][3], a3 = e[2][1], a4 = e[3][0], a5 = e[1][3], a6 = e[0][2], a7 = e[2][2], a8 = e[1][1], a9 = e[2][3], a10 = e[0][1], a11 = e[3][1], a12 = e[2][0], a13 = e[3][2], a14 = e[3][3], a15 = e[1][0], a16 = e[0][0]; ggHMatrix3 m; m.e[0][0] = a8*a7*a14 - a8*a9*a13 - a3*a1*a14 + a3*a5*a13 + a11*a1*a9 - a11* a5*a7; m.e[0][1] = -(a10*a7*a14 - a10*a9*a13 - a3*a6*a14 + a3*a2*a13 + a11*a6*a9 - a11*a2*a7); m.e[0][2] = a10*a1*a14 - a10*a5*a13 - a8*a6*a14 + a8*a2*a13 + a11*a6*a5 - a1 1*a2*a1; m.e[0][3] = -(a10*a1*a9 - a10*a5*a7 - a8*a6*a9 + a8*a2*a7 + a3*a6*a5 - a3*a2 *a1); m.e[1][0] = -(a15*a7*a14 - a15*a9*a13 - a12*a1*a14 + a12*a5*a13 + a4*a1*a9 - a4*a5*a7); m.e[1][1] = a16*a7*a14 - a16*a9*a13 - a12*a6*a14 + a12*a2*a13 + a4*a6*a9 - a 4*a2*a7; m.e[1][2] = -(a16*a1*a14 - a16*a5*a13 - a15*a6*a14 + a15*a2*a13 + a4*a6*a5 - a4*a2*a1); m.e[1][3] = a16*a1*a9 - a16*a5*a7 - a15*a6*a9 + a15*a2*a7 + a12*a6*a5 - a12* a2*a1; m.e[2][0] = a15*a3*a14 - a15*a9*a11 - a12*a8*a14 + a12*a5*a11 + a4*a8*a9 - a 4*a5*a3; m.e[2][1] = -(a16*a3*a14 - a16*a9*a11 - a12*a10*a14 + a12*a2*a11 + a4*a10*a9 - a4*a2*a3); m.e[2][2] = a16*a8*a14 - a16*a5*a11 - a15*a10*a14 + a15*a2*a11 + a4*a10*a5 - a4*a2*a8; m.e[2][3] = -(a16*a8*a9 - a16*a5*a3 - a15*a10*a9 + a15*a2*a3 + a12*a10*a5 - a12*a2*a8); m.e[3][0] = -(a15*a3*a13 - a15*a7*a11 - a12*a8*a13 + a12*a1*a11 + a4*a8*a7 - a4*a1*a3); m.e[3][1] = a16*a3*a13 - a16*a7*a11 - a12*a10*a13 + a12*a6*a11 + a4*a10*a7 - a4*a6*a3; m.e[3][2] = -(a16*a8*a13 - a16*a1*a11 - a15*a10*a13 + a15*a6*a11 + a4*a10*a1 - a4*a6*a8); m.e[3][3] = a16*a8*a7 - a16*a1*a3 - a15*a10*a7 + a15*a6*a3 + a12*a10*a1 - a1 2*a6*a8; // divide each matrix element by the determinant d = 1/d; // in case * is faster than / for (int r=0; r<4; r++) for (int c=0; c<4; c++) m.e[r][c] *= d; return m; And the determinant code: double ggHMatrix3::determinant() const { return e[0][0] * (e[1][1] * (e[2][2] * e[3][3] - e[2][3] * e[3][2]) + e[1][2] * (e[2][3] * e[3][1] - e[2][1] * e[3][3]) + e[1][3] * (e[2][1] * e[3][2] - e[2][2] * e[3][1])) - e[0][1] * (e[1][0] * (e[2][2] * e[3][3] - e[2][3] * e[3][2]) + e[1][2] * (e[2][3] * e[3][0] - e[2][0] * e[3][3]) + e[1][3] * (e[2][0] * e[3][2] - e[2][2] * e[3][0])) + e[0][2] * (e[1][0] * (e[2][1] * e[3][3] - e[2][3] * e[3][1]) + e[1][1] * (e[2][3] * e[3][0] - e[2][0] * e[3][3]) + e[1][3] * (e[2][0] * e[3][1] - e[2][1] * e[3][0])) - e[0][3] * (e[1][0] * (e[2][1] * e[3][2] - e[2][2] * e[3][1]) + e[1][1] * (e[2][2] * e[3][0] - e[2][0] * e[3][2]) + e[1][2] * (e[2][0] * e[3][1] - e[2][1] * e[3][0])); }

Всего 8 фpагмент(а/ов) |пpедыдущий фpагмент (8)

Если вы хотите дополнить FAQ - пожалуйста пишите.

design/collection/some content by Frog,
DEMO DESIGN FAQ (C) Realm Of Illusion 1994-2000,
При перепечатке материалов этой страницы пожалуйста ссылайтесь на источник: "DEMO.DESIGN FAQ, http://www.enlight.ru/demo/faq".