``````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; cx [1][1] = a.x [1][1] * b; cx [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;
}
Vector3D operator *= ( const Matrix3D& a, const Vector3D& b ) {
Vector3D v;
v.x = a.x [0][0]*b.x + a.x [0][1]*b.y + a.x [0][2]*b.z; v.y = a.x [1][0]*b.x + a.x [1][1]*b.y + a.x [1][2]*b.z; v.z = a.x [2][0]*b.x + a.x [2][1]*b.y + a.x [2][2]*b.z;
return v;
}
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIHIIIIIIIIIIIIIII
Matrix3D scale ( const Vector3D& v ) {
Matrix3D a ( 1.0 );``````

9. Преобразования в пространстве, проектировани а.х [0][0] = v.x; а.х [1][1] = v.y; а.х [2][2] = v.z;

return а;

``````}
Matrix3D rotateX (float angle ) {
Matrix3D a(1.0);
float cosine = cos ( angle ); float sine = sin ( angle );
a.x = cosine; a.x [1][2] = sine; a.x [2][1] = -sine; a.x [2][2] = cosine;
return a;
}
Matrix3D rotateY (float angle ) {
Matrix3Da( 1.0);
float cosine = cos ( angle );
float sine = sin ( angle );
a.x [0][0] = c6sine; a.x [0][2] = sine; a.x [2][0] = -sine; a.x [2][2] = cosine;
return a;
}
Matrix3D rotateZ (float angle ) {
Matrix3D a (1.0 );
float cosine = cos ( angle );
float sine = sin (angle );
a.x [0][0] = cosine; a.x [0][1] = sine; a.x [1][0] = -sine; a.x = cosine;
return a;
}
Matrix3D rotate ( const Vector3D& v, float angle ) {
Matrix3D a;
float cosine = cos ( angle ); float sine = sin ( angle );
a.x [0][0] = v.x *v.x + (1-v.x*v.x) * cosine; a.x [0][1] = v.x *v.y * (1-cosine) + v.z * sine; a.x [0][2] = v.x *v.z * (1-cosine) - v.y * sine; a.x [1][0] = v.x *v.y * (1-cosine) - v.z * sine;``````

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

``````a.x [1][1] = v.y *v.y + (1-v.y*v.y) * cosine; a.x [1][2] = v.y *v.z * (1-cosine) + v.x * sine; a.x [2][0] = v.x *v.z * (1-cosine) + v.y * sine; a.x [2][1] = v.y *v.z * (1-cosine) - v.x * sine; a.x [2][2] = v.z *v.z + (1-v.z*v.z) * cosine;
return a;
}
Matrix3D mirrorX () {``````

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