Реферат: Трехмерная графика Теория

#include <math.h>#include "matrix.h"Matrix :: Matrix ( double v ){ int j; for ( int i = 0; i < 4; i++ ) for ( j = 0; j < 4; j++ ) x [i][j] = ( i == j ) ? v : 0.0; x [3][3] = 1;}void Matrix :: Invert ()

{

Matrix Out ( 1 );

for ( int i = 0; i < 4; i++ ) {

double d = x [i][i];

if ( d != 1.0 ) {

for ( int j = 0; j < 4; j++ ) {

Out.x [i][j] /= d;

x [i][j] /= d;

}

}

for ( int j = 0; j < 4; j++ ) {

if ( j != i ) {

if ( x[j][i] != 0.0 ) {

double mulby = x[j][i];

for ( int k = 0; k < 4; k++ ) {

x [j][k] -= mulby * x [i][k];

Out.x [j][k] -= mulby * Out.x [i][k];

}

}

}

}

}

*this = Out;

}

void Matrix :: Transpose ()

{

double t;

int j;

К-во Просмотров: 1926
Бесплатно скачать Реферат: Трехмерная графика Теория