Реферат: Трехмерная графика Теория
return res;
}
Matrix operator * ( const Matrix& A, const Matrix& B )
{
Matrix res;
int j;
for ( int i = 0; i < 4; i++ )
for ( j = 0; j < 4; j++ ) {
double sum = 0;
for ( int k = 0; k < 4; k++ )
sum += A.x [i][k] * B.x [k][j];
res.x [i][j] = sum;
}
return res;
}
Matrix operator * ( const Matrix& A, double v )
{
Matrix res;
int j;
for ( int i = 0; i < 4; i++ )
for ( j = 0; j < 4; j++ )
res.x [i][j] = A.x [i][j] * v;
return res;
}
Vector operator * ( const Matrix& M, const Vector& v )
{
Vector res;
res.x = v.x * M.x [0][0] + v.y * M.x [1][0] + v.z * M.x [2][0] + M.x [3][0];
res.y = v.x * M.x [0][1] + v.y * M.x [1][1] + v.z * M.x [2][1] + M.x [3][1];