9. ripeo6pa30BaHWfl b npodpaHCTBe, npoeKTupoBaHn

а.х[2][2] = х[2][2]; *this = а;

}
Matrix3D operator + ( const Matrix3D& a, const Matrix3D& b ) {
Matrix3D c;
cx [0][0] = a.x [0][0] + b.x [0][0]; cx [0][1] = a.x [0][1] + b.x [0][1]; cx [0][2] = a.x [0][2] + b.x [0][2]; c.x[1][0] = a.x[1]t0] + b.x[1][0]; cx [1][1] = a.x [1][1] + b.x [1][1]; cx [1][2] = a.x [1][2] + b.x [1][2]; cx [2][0] = a.x [2][0] + b.x [2][0]; cx [2][1] = a.x[2][1] + b.x [2][1]; cx [2][2] = a.x [2][2] + b.x [2][2];
return c;
}
Matrix3D operator - ( const Matrix3D& a, const Matrix3D& b ) {
Matrix3D c;
cx [0][0] = a.x [0][0] - b.x [0][0]; cx [0][1] = a.x [0][1]-b.x [0][1]; cx [0][2] = a.x [0][2] - b.x [0][2]; cx [1][0] = a.x [1][0]-b.x [1][0]; cx [1][1] = a.x [1][1]-b.x [1][1]; c.x[1][2] = a.x[1][2]-b.x[1][2]; cx [2][0] = a.x [2][0] - b.x [2][0]; cx [2][1] = a.x [2][1]-b.x [2][1]; cx [2][2] = a.x [2][2] - b.x [2][2];
return c;
}
Matrix3D operator * ( const Matrix3D& a, const Matrix3D& b ) {

Matrix3D с ( a );

c.x[0][0]=a.x[0][0]*b.x[0][0]+a.x[0][1]*b.x[1][0]+
a.x[0][2]*b.x[2][0]; c.x[0][1]=a.x[0][0]*b.x[0][1]+a.x[0][1]*b.x[1][1]+
a.x[0][2]*b.x[2][1]; c.x[0][2]=a.x[0][0]*b.x[0][2]+a.x[0][1]*b.x[1][2]+
a.x[0][2]*b.x[2][2]; cx[1][0]=a.x[1][0]*b.x[0][0]+a.x[1][1]*b.x[1][0]+
a.x[1][2]*b.x[2][0]; cx[1][1]=a.x[1p]*b.x[0][1]+a.x[1][1]*b.x[1][1]+
a.x[1][2]*b.x[2][1]; c.x[1][2]=a.x[1][0]*b.x[0]l2]+a.x[1][1]*b.x[1][2]+
a.x[1][2]*b.x[2][2]; c.x[2][0]=a.x[2][0]*b.x[0][0]+a.x[2][1]*b.x[1][0]+
a.x[2][2]*b.x[2][0];

Компьютерная графика. Полигональные модели

c.x[2][1]=a.x[2][0]*b.x[0][1]+a.x[2][1]*b.x[1][1]+
a.x[2][2]*b.x[2][1]; c.x[2][2]=a.x[2][0]*b.x[0][2]+a.x[2][1]*b.x[1][2]+
a.x[2][2]*b.x[2][2];
return c;
}
Matrix3D operator * ( const Matrix3D& a, float b ) {
Matrix3D c;
cx [0][0] = a.x [0][0] * b; cx [0][1] = a.x [0][1]*b; cx [0][2] = a.x [0][2] * b; cx [1][0] = a.x [1][0]*b; c.x[1][1] = a.x[1][1]*b; c.x[1][2] = a.x [1][2]*b; cx [2][0] = a.x [2][0] * b; cx [2][1] = a.x [2][1]*b; cx [2][0] = a.x [0][0] * b;
return c;
}
Matrix3D operator * (float b, const Matrix3D& a ) {

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