- flags(IDENTITY)
-{
- copy(m, m+16, matrix);
- check_flags();
-}
-
-Matrix::Matrix(const double *m):
- flags(IDENTITY)
-{
- copy(m, m+16, matrix);
- check_flags();
-}
-
-void Matrix::check_flags()
-{
- const double *m = matrix;
- if(m[12]!=0 || m[13]!=0 || m[14]!=0)
- flags |= TRANSLATE;
- if(m[0]!=1)
- {
- flags |= SCALE;
- if(m[5]!=m[0] || m[10]!=m[0])
- flags |= ARBITARY;
- }
- if(m[1]!=0 || m[2]!=0 || m[4]!=0 || m[6]!=0 || m[8]!=0 || m[9]!=0)
- {
- flags |= ROTATE;
- double x_dot_y = m[0]*m[1]+m[4]*m[5]+m[8]*m[9];
- double x_dot_z = m[0]*m[2]+m[4]*m[6]+m[8]*m[10];
- double y_dot_z = m[1]*m[2]+m[5]*m[6]+m[9]*m[10];
- if(x_dot_y!=0 || x_dot_z!=0 || y_dot_z!=0)
- flags |= ARBITARY;
- }
- if(m[3]!=0 || m[7]!=0 || m[11]!=0 || m[15]!=1)
- flags |= ARBITARY;
-}
-
-void Matrix::multiply(const Matrix &other)
-{
- *this = *this*other;
-}
-
-void Matrix::translate(double x, double y, double z)
-{
- multiply(translation(x, y, z));
-}
-
-void Matrix::rotate(double a, double x, double y, double z)
-{
- multiply(rotation(a, x, y, z));
-}
-
-void Matrix::rotate_deg(double a, double x, double y, double z)
-{
- multiply(rotation_deg(a, x, y, z));
-}
-
-void Matrix::scale(double s)
-{
- multiply(scaling(s));
-}