You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB
C++

//////////////////////////////////////////////////////////////////////////////
//文件 Matrix2D.h
//主要功能:
//
//程序编写: 2005-12-07
/////////////////////////////////////////////////////////////////////////////
#pragma once
//For any coordinates (x, y) in world space, the transformed coordinates in page
//space (x', y') can be determined by the following algorithm:
//x' = x * eM11 + y * eM21 + eDx,
//y' = x * eM12 + y * eM22 + eDy,
//where the transformation matrix is represented by the following:
// | eM11 eM12 | | 1 0 | | m[0] m[1] |
//Matrix = | eM21 eM22 | = | 0 1 | = | m[2] m[3] |
// | eDx eDy | | 0 0 | | m[4] m[5] |
class CMatrix2D
{
public:
CMatrix2D(void);
virtual ~CMatrix2D(void);
bool IsIdentity(void);
void Reset(void); // set identity matrix elements
void SetMatrix(double m11, double m12, double m21, double m22, double dx, double dy);
void SetMatrix(double *pm); //6个
void RotateAt(double centerX, double centerY, double angle);
void Rotate(double angle);
void Translate(double dx, double dy); //平移变换
void Shear(double shearX, double shearY); //错切变换
void Scale(double scaleX, double scaleY); //比例缩放
double Determinant();
CMatrix2D Invert(bool *invertible);
void operator=(const CMatrix2D& md);
void operator*=(const CMatrix2D& md);
void Exchange(double& x, double& y, BOOL bUndo=FALSE); //当bUndo=TRUE时进行反变换
void Exchange(long& x, long& y, BOOL bUndo=FALSE); //当bUndo=TRUE时进行反变换
BOOL GetElements(double* pele);
BOOL GetElements(float* pele);
protected:
double mt[6];
};