2D Transformation Matrix  
 More...
#include <mat2d.h>
 | 
| void  | PrepDrawImg (int ws, int hs, int x0, int y0, int wd, int hd, float shearx, float sheary, float r, float tx, float ty) | 
|   | Prepare transformation matrix (for DrawImgMat() function)  More...
  | 
|   | 
| void  | ExportInt (int *mat) const | 
|   | Export matrix to int array[6].  More...
  | 
|   | 
| 
float  | GetX (float x, float y) const | 
|   | Transform X. 
  | 
|   | 
| 
float  | GetY (float x, float y) const | 
|   | Transform Y. 
  | 
|   | 
| 
void  | Unit () | 
|   | Set unit matrix. 
  | 
|   | 
| 
void  | Copy (const cMat2D *m) | 
|   | Copy matrix. 
  | 
|   | 
| void  | TransX (float tx) | 
|   | Translate in X direction.  More...
  | 
|   | 
| void  | TransY (float ty) | 
|   | Translate in Y direction.  More...
  | 
|   | 
| void  | ScaleX (float sx) | 
|   | Scale in X direction.  More...
  | 
|   | 
| void  | ScaleY (float sy) | 
|   | Scale in Y direction.  More...
  | 
|   | 
| void  | RotSC (float sina, float cosa) | 
|   | Rotate, using sin and cos.  More...
  | 
|   | 
| 
void  | Rot (float a) | 
|   | Rotate, using angle. 
  | 
|   | 
| 
void  | Rot90 () | 
|   | Rotate by 90 deg (sina=1, cosa=0) 
  | 
|   | 
| 
void  | Rot180 () | 
|   | Rotate by 180 deg (=flipX and flipY) (sina=0, cosa=-1) 
  | 
|   | 
| 
void  | Rot270 () | 
|   | Rotate by 270 deg (sina=-1, cosa=0) 
  | 
|   | 
| void  | ShearX (float dx) | 
|   | Shear in X direction.  More...
  | 
|   | 
| void  | ShearY (float dy) | 
|   | Shear in Y direction.  More...
  | 
|   | 
| void  | FlipY () | 
|   | Flip in Y direction.  More...
  | 
|   | 
| void  | FlipX () | 
|   | Flip in X direction.  More...
  | 
|   | 
 | 
| 
float  | m11 | 
|   | 
| 
float  | m12 | 
|   | 
| 
float  | m13 | 
|   | 
| 
float  | m21 | 
|   | 
| 
float  | m22 | 
|   | 
| 
float  | m23 | 
|   | 
2D Transformation Matrix 
Some rendering functions use the cMat2Df transformation matrix to define image transformation. The matrix has 6 numeric elements of float type. The transformation is prepared by setting the initial state with the Unit function and then entering the transformations one by one. Using the matrix, operations are performed on the image as if the operations were entered sequentially. 
 
◆ PrepDrawImg()
      
        
          | void cMat2Df::PrepDrawImg  | 
          ( | 
          int  | 
          ws,  | 
        
        
           | 
           | 
          int  | 
          hs,  | 
        
        
           | 
           | 
          int  | 
          x0,  | 
        
        
           | 
           | 
          int  | 
          y0,  | 
        
        
           | 
           | 
          int  | 
          wd,  | 
        
        
           | 
           | 
          int  | 
          hd,  | 
        
        
           | 
           | 
          float  | 
          shearx,  | 
        
        
           | 
           | 
          float  | 
          sheary,  | 
        
        
           | 
           | 
          float  | 
          r,  | 
        
        
           | 
           | 
          float  | 
          tx,  | 
        
        
           | 
           | 
          float  | 
          ty  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Prepare transformation matrix (for DrawImgMat() function) 
The order of operations is chosen as if the image is first moved to the point tx and ty, scaled, skewed, then rotated and finally moved to the target coordinates. 
- Parameters
 - 
  
    | ws | Source image width  | 
    | hs | Source image height  | 
    | x0 | Reference point X on source image  | 
    | y0 | Reference point Y on source image  | 
    | wd | Destination image width (negative = flip image in X direction)  | 
    | hd | Destination image height (negative = flip image in Y direction)  | 
    | shearx | Shear image in X direction  | 
    | sheary | Shear image in Y direction  | 
    | r | Rotate image (angle in radians)  | 
    | tx | Shift in X direction (ws = whole image width)  | 
    | ty | Shift in Y direction (hs = whole image height)  | 
  
   
 
 
◆ ExportInt()
      
        
          | void cMat2Df::ExportInt  | 
          ( | 
          int *  | 
          mat | ) | 
           const | 
        
      
 
Export matrix to int array[6]. 
After transformation, the lower 12 bits of the number contain the decimal part of the number, the upper 20 bits contain the integer part of the number. Rendering functions require this integer form of the transformation matrix. 
 
 
◆ TransX()
  
  
      
        
          | void cMat2D< float  >::TransX  | 
          ( | 
          float  | 
          tx | ) | 
           | 
         
       
   | 
  
inlineinherited   | 
  
 
Translate in X direction. 
 1  0 tx   m11 m12 m13   m11 m12 m13+tx
 0  1  0 * m21 m22 m23 = m21 m22 m23
 0  0  1     0   0   1    0   0   1
 
 
 
◆ TransY()
  
  
      
        
          | void cMat2D< float  >::TransY  | 
          ( | 
          float  | 
          ty | ) | 
           | 
         
       
   | 
  
inlineinherited   | 
  
 
Translate in Y direction. 
 1  0  0   m11 m12 m13   m11 m12 m13
 0  1 ty * m21 m22 m23 = m21 m22 m23+ty
 0  0  1     0   0   1    0   0   1
 
 
 
◆ ScaleX()
  
  
      
        
          | void cMat2D< float  >::ScaleX  | 
          ( | 
          float  | 
          sx | ) | 
           | 
         
       
   | 
  
inlineinherited   | 
  
 
Scale in X direction. 
 sx 0  0   m11 m12 m13    m11*sx m12*sx m13*sx
 0  1  0 * m21 m22 m23  = m21    m22    m23
 0  0  1     0   0   1      0      0      1
 
 
 
◆ ScaleY()
  
  
      
        
          | void cMat2D< float  >::ScaleY  | 
          ( | 
          float  | 
          sy | ) | 
           | 
         
       
   | 
  
inlineinherited   | 
  
 
Scale in Y direction. 
 1  0  0   m11 m12 m13    m11    m12    m13
 0  sy 0 * m21 m22 m23  = m21*sy m22*sy m23*sy
 0  0  1     0   0   1      0      0      1
 
 
 
◆ RotSC()
  
  
      
        
          | void cMat2D< float  >::RotSC  | 
          ( | 
          float  | 
          sina,  | 
         
        
           | 
           | 
          float  | 
          cosa  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inlineinherited   | 
  
 
Rotate, using sin and cos. 
 cosa -sina  0   m11 m12 m13   m11*cosa-m21*sina  m12*cosa-m22*sina  m13*cosa-m23*sina
 sina  cosa  0 * m21 m22 m23 = m11*sina+m21*cosa  m12*sina+m22*cosa  m13*sina+m23*cosa
  0      0   1     0   0   1           0                    0                 1
 
 
 
◆ ShearX()
  
  
      
        
          | void cMat2D< float  >::ShearX  | 
          ( | 
          float  | 
          dx | ) | 
           | 
         
       
   | 
  
inlineinherited   | 
  
 
Shear in X direction. 
 1  dx 0   m11 m12 m13   m11+m21*dx m12+m22*dx m13+m23*dx
 0  1  0 * m21 m22 m23 = m21        m22        m23
 0  0  1     0   0   1     0          0          1
 
 
 
◆ ShearY()
  
  
      
        
          | void cMat2D< float  >::ShearY  | 
          ( | 
          float  | 
          dy | ) | 
           | 
         
       
   | 
  
inlineinherited   | 
  
 
Shear in Y direction. 
 1  0  0   m11 m12 m13   m11        m12        m13
 dy 1  0 * m21 m22 m23 = m21+m11*dy m22+m12*dy m23+m13*dy
 0  0  1     0   0   1     0          0          1
 
 
 
◆ FlipY()
  
  
      
        
          | void cMat2D< float  >::FlipY  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inlineinherited   | 
  
 
Flip in Y direction. 
 1  0  0   m11 m12 m13     m11   m12    m13
 0 -1  0 * m21 m22 m23  = -m21  -m22   -m23
 0  0  1     0   0   1      0     0      1
 
 
 
◆ FlipX()
  
  
      
        
          | void cMat2D< float  >::FlipX  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inlineinherited   | 
  
 
Flip in X direction. 
 -1 0  0   m11 m12 m13    -m11  -m12   -m13
 0  1  0 * m21 m22 m23  = m21    m22    m23
 0  0  1     0   0   1      0      0      1
 
 
 
The documentation for this class was generated from the following files:
- src/util/mat2d.h
 
- src/util/mat2d.cpp