📄 as_matrix.hxx
字号:
// Header for matrix.// This class stands for a 3x3 Euclidean affine transformation. // Note that it is NOT a tensor.#if !defined( MATRIX_CLASS )#define MATRIX_CLASS#include "as_vector.hxx"class transf;class matrix { double elem[3][3]; // components of 3x3 matrix void zero();public: matrix() {} // allow unitialised matrices // Construct a matrix from three vectors for its rows. matrix( vector const &, vector const &, vector const & ); // Extract an element of the matrix. double element( int row, int col ) const { return elem[ row ][ col ]; } // Extract a row of a matrix vector column(int in_col) const { return vector(elem[0][in_col],elem[1][in_col],elem[2][in_col]); } // Extract a column of a matrix vector row(int in_row) const { return vector(elem[in_row][0],elem[in_row][1],elem[in_row][2]); } // Set element value. void set_element( int row, int col, double new_e ) { elem[ row ][ col ] = new_e; } // Return the transpose of the matrix. matrix transpose() const; // return the determinant double determinant() const; // STI let (10/98): Added a new member function // return the inverse of a matrix matrix inverse() const; // STI let (10/98): Added a new member function // Determine if a matrix is the identity matrix logical is_identity() const; // Multiply two matrices. friend matrix operator*( matrix const &, matrix const & ); matrix const &operator*=( matrix const & ); // Multiply a matrix by a double friend matrix operator*( double const &, matrix const & ); matrix const &operator*=( double const & ); // Transform a vector by a matrix. friend vector operator*( matrix const &, vector const & ); friend vector operator*( vector const &, matrix const & ); // Transform a position by a matrix. friend position operator*( matrix const &, position const & ); friend position operator*( position const &, matrix const & ); // Determine if 2 matixes are equal, given some resolution friend logical same_matrix( matrix const&, matrix const&, const double res = resabs); // "Constructors" for particular types of transformation. // These are not actually constructors because there is // insufficient information in their argument types to // identify the different cases. // Form matrix for equal scaling. friend matrix scaling( double ); // Form matrix for differential scaling. friend matrix scaling( double, double, double ); // Form matrix for differential scaling. friend matrix scaling( vector ); // Form matrix for rotation by angle about vector. friend matrix rotation( double, vector const & ); // Form matrix for reflection about a plane through the origin // with the given vector as normal. friend matrix reflection( vector const & ); // Output details of a matrix. // Transform a matrix i.e. by an affine transformation. friend matrix operator*( matrix const &, transf const & ); friend matrix operator*( matrix const &, transf const * ); matrix const &operator*=( transf const & );};// Tests for equalinline logical operator==( matrix const &m1, matrix const &m2 ) { return same_matrix( m1, m2, resnor ); }inline logical operator!=( matrix const &m1, matrix const &m2 ) { return !same_matrix( m1, m2, resnor ); }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -