classify/xform2d.h

Go to the documentation of this file.
00001 
00019 #ifndef   XFORM2D_H
00020 #define   XFORM2D_H
00021 
00022 /* =================
00023           Include Files and Type Defines
00024  ==================== */
00025 #include "fpoint.h"
00026 
00035 typedef struct
00036 {
00037   FLOAT32 a, b, c, d, tx, ty;
00038 } MATRIX_2D, *MATRIX_2D_PTR;
00039 
00040 /* =================
00041           Macros
00042  ==================== */
00044 #define InitMatrix(M)      ((M)->a = 1, (M)->b = 0,      \
00045             (M)->c = 0, (M)->d = 1,    \
00046             (M)->tx = 0, (M)->ty = 0 )
00047 
00049 #define CopyMatrix(A,B)    ((B)->a = (A)->a, (B)->b = (A)->b,  \
00050             (B)->c = (A)->c, (B)->d = (A)->d,   \
00051             (B)->tx = (A)->tx, (B)->ty = (A)->ty)
00052 
00054 #define TranslateMatrix(M,X,Y)   ((M)->tx += (M)->a * (X) + (M)->c * (Y),  \
00055             (M)->ty += (M)->b * (X) + (M)->d * (Y) )
00056 
00058 #define ScaleMatrix(M,X,Y) ((M)->a *= (X), (M)->b *= (X),      \
00059             (M)->c *= (Y), (M)->d *= (Y))
00060 
00062 #define MirrorMatrixInX(M)  (ScaleMatrix((M),-1,1))
00063 
00064 #define MirrorMatrixInY(M)  (ScaleMatrix((M),1,-1))
00065 
00066 #define MirrorMatrixInXY(M) (ScaleMatrix((M),-1,-1))
00067 
00069 #define MapX(M,X,Y)   ((M)->a * (X) + (M)->c * (Y) + (M)->tx)
00070 
00071 #define MapY(M,X,Y)   ((M)->b * (X) + (M)->d * (Y) + (M)->ty)
00072 /* using a matrix to map points */
00073 #define MapPoint(M,A,B)    (Xof(B) = MapX (M, Xof(A), Yof(A)), \
00074             Yof(B) = MapY (M, Xof(A), Yof(A)))
00075 #define MapDx(M,DX,DY)    ((M)->a * (DX) + (M)->c * (DY))
00076 #define MapDy(M,DX,DY)    ((M)->b * (DX) + (M)->d * (DY))
00077 
00078 /* =================
00079           Public Function Prototypes
00080  ==================== */
00081 void RotateMatrix(MATRIX_2D_PTR Matrix, FLOAT32 Angle); 
00082 #endif

Generated on Wed Feb 28 19:49:10 2007 for Tesseract by  doxygen 1.5.1