float mulBy = xfj][i];
for (int k = 0; k < 4; k++ ) {
x 0][k] -= mulBy * x [i][k]; out.x [j][k] -= mulBy * out.x [i][kj;
}
}
}
}
}
*this = out;
}
void Matrix :: transpose ()
{
float t;
for (register int i = 0; i < 4; i++ )
for (register int j = i; j < 4; j++ ) if(i!=j)
{
t = x mi.
x [i]D] = x mi. x [j][i] = t;
}
}
Matrix& Matrix :: operator += (const Matrix& a )
{
for (register int i = 0; i < 4; i++ )
for (register int j = 0; j < 4; j++ ) x [i][j] += a.x [i]Q];
return *this;
}
Matrix& Matrix :: operator -= ( const Matrix& a )
{
for (register int i = 0; i < 4; i++ )
for (register int j = 0; j < 4; j++ ) x [i][j] -= a.x mi.
return *this;
}
Matrix& Matrix :: operator *= (float v)
{
for ( register int i = 0; i < 4; i++ )
for (register int j = 0; j < 4; j++ )
9. ripeo6pa30BaHHfl b npocipaHCTBe, npoeKTHpoBaHH
x [i]0] *= v;
return *this;
}
Matrix& Matrix :: operator *= ( const Matrix& a )
{
Matrix res (*this );
for (int i = 0; i < 4; i++ )
for (int j = 0; j < 4; j++ )
{
float sum = 0;
for (int k = 0; k < 4; k++ )
sum += res.x [i][k] * a.x [k][j];
x [i]D] = sum;
}
return *this;
}
Matrix operator + ( const Matrix& a, const Matrix& b )
{
Matrix res;
for (register int i = 0; i < 4; i++ )
for (register int j = 0; j < 4; j++ )
res.x [i][j] = a.x [i]D] + b.x [i]D];
return res;
}
Matrix operator - ( const Matrix& a, const Matrix& b )
{
Matrix res;
for (register int i = 0; i < 4; i++ )
for (register int j = 0; j < 4; j++ )
res.x [i]0] = a.x [i][j] - b.x [i]Q];
return res;
}
Matrix operator * ( const Matrix& a, const Matrix& b )
{
Matrix res;
for (register int i = 0; i < 4; i++ )
for (> register int j = 0; j < 4; j++ )
{
float sum = 0;
for (register 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, float v )
{
Matrix res;
for ( register int i = 0; i < 4; i++ )
for ( register int j = 0; j < 4; j++ ) res.x [i][j] = a.x [i][j] * v;

⇐ Предыдущая| |Следующая ⇒