Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Functions
xform2d.h File Reference
`#include "fpoint.h"`

Go to the source code of this file.

## Classes

struct | MATRIX_2D

## Typedefs

typedef struct MATRIX_2D * | MATRIX_2D_PTR

## Functions

void | InitMatrix (MATRIX_2D *M)
void | CopyMatrix (MATRIX_2D *A, MATRIX_2D *B)
void | TranslateMatrix (MATRIX_2D *M, FLOAT32 X, FLOAT32 Y)
void | ScaleMatrix (MATRIX_2D *M, FLOAT32 X, FLOAT32 Y)
void | MirrorMatrixInX (MATRIX_2D *M)
void | MirrorMatrixInY (MATRIX_2D *M)
void | MirrorMatrixInXY (MATRIX_2D *M)
FLOAT32 | MapX (MATRIX_2D *M, FLOAT32 X, FLOAT32 Y)
FLOAT32 | MapY (MATRIX_2D *M, FLOAT32 X, FLOAT32 Y)
void | MapPoint (MATRIX_2D *M, const FPOINT &A, FPOINT *B)
FLOAT32 | MapDx (MATRIX_2D *M, FLOAT32 DX, FLOAT32 DY)
FLOAT32 | MapDy (MATRIX_2D M, FLOAT32 DX, FLOAT32 DY)
void | RotateMatrix (MATRIX_2D_PTR Matrix, FLOAT32 Angle)

## Typedef Documentation

typedef struct MATRIX_2D * MATRIX_2D_PTR

## Function Documentation

void CopyMatrix | ( | MATRIX_2D * | A,
|  | MATRIX_2D * | B
| ) |  |

Definition at line 37 of file xform2d.cpp.

{
B->a = A->a;
B->b = A->b;
B->c = A->c;
B->d = A->d;
B->tx = A->tx;
B->ty = A->ty;
}

void InitMatrix | ( | MATRIX_2D * | M | ) |

Public Function Prototypes —————————————————————————-

Include Files and Type Defines —————————————————————————- ---------------------------------------------------------------------------- Public Code —————————————————————————-

Definition at line 28 of file xform2d.cpp.

{
M->a = 1;
M->b = 0;
M->c = 0;
M->d = 1;
M->tx = 0;
M->ty = 0;
}

FLOAT32 MapDx | ( | MATRIX_2D * | M,
|  | FLOAT32 | DX,
|  | FLOAT32 | DY
| ) |  |

Definition at line 75 of file xform2d.cpp.

{
return M->a * DX + M->c * DY;
}

FLOAT32 MapDy | ( | MATRIX_2D | M,
|  | FLOAT32 | DX,
|  | FLOAT32 | DY
| ) |  |

void MapPoint | ( | MATRIX_2D * | M,
|  | const FPOINT & | A,
|  | FPOINT * | B
| ) |  |

Definition at line 70 of file xform2d.cpp.

{
B->x = MapX(M, A.x, A.y);
B->y = MapY(M, A.x, A.y);
}

FLOAT32 MapX | ( | MATRIX_2D * | M,
|  | FLOAT32 | X,
|  | FLOAT32 | Y
| ) |  |

Definition at line 62 of file xform2d.cpp.

{
return M->a * (X) + (M)->c * (Y) + (M)->tx;
}

FLOAT32 MapY | ( | MATRIX_2D * | M,
|  | FLOAT32 | X,
|  | FLOAT32 | Y
| ) |  |

Definition at line 66 of file xform2d.cpp.

{
return M->b * X + M->d * Y + M->ty;
}

void MirrorMatrixInX | ( | MATRIX_2D * | M | ) |

Definition at line 58 of file xform2d.cpp.

{ScaleMatrix(M, -1, 1);}

void MirrorMatrixInXY | ( | MATRIX_2D * | M | ) |

Definition at line 60 of file xform2d.cpp.

{ScaleMatrix(M, -1, -1);}

void MirrorMatrixInY | ( | MATRIX_2D * | M | ) |

Definition at line 59 of file xform2d.cpp.

{ScaleMatrix(M, 1, -1);}

void RotateMatrix | ( | MATRIX_2D_PTR | Matrix,
|  | FLOAT32 | Angle
| ) |  |

Definition at line 85 of file xform2d.cpp.

{
/*
** Parameters:
** Matrix transformation matrix to rotate
** Angle angle to rotate matrix
** Globals: none
** Operation:
** Rotate the coordinate system (as specified by Matrix) about
** its origin by Angle radians. In matrix notation the
** effect is as follows:
**
** Matrix = R X Matrix
**
** where R is the following matrix
**
** cos Angle sin Angle 0
** -sin Angle cos Angle 0
** 0 0 1
** Return: none
** Exceptions: none
** History: 7/27/89, DSJ, Create.
*/
FLOAT32 Cos, Sin;
FLOAT32 NewA, NewB;
Cos = cos ((double) Angle);
Sin = sin ((double) Angle);
NewA = Matrix->a * Cos + Matrix->c * Sin;
NewB = Matrix->b * Cos + Matrix->d * Sin;
Matrix->c = Matrix->a * -Sin + Matrix->c * Cos;
Matrix->d = Matrix->b * -Sin + Matrix->d * Cos;
Matrix->a = NewA;
Matrix->b = NewB;
} /* RotateMatrix */

void ScaleMatrix | ( | MATRIX_2D * | M,
|  | FLOAT32 | X,
|  | FLOAT32 | Y
| ) |  |

Definition at line 51 of file xform2d.cpp.

{
M->a *= X;
M->b *= X;
M->c *= Y;
M->d *= Y;
}

void TranslateMatrix | ( | MATRIX_2D * | M,
|  | FLOAT32 | X,
|  | FLOAT32 | Y
| ) |  |

Definition at line 46 of file xform2d.cpp.

{
M->tx += M->a * X + M->c * Y;
M->ty += M->b * X + M->d * Y;
}