以下均为MFC工程代码
代码一:简单实现
void CGeotranView::Onyuantu()
{
// 原图,画三角形
CDC *pDC=GetDC();
pDC->MoveTo(100,100);
pDC->LineTo(200,50);
pDC->LineTo(200,150);
pDC->LineTo(100,100);
ReleaseDC(pDC);
}
void CGeotranView::Ontranslation()
{
// 平移 tx=50,ty=60
CDC *pDC=GetDC();
int tx=50,ty=60;
pDC->MoveTo(100+tx,100+ty);
pDC->LineTo(200+tx,50+ty);
pDC->LineTo(200+tx,150+ty);
pDC->LineTo(100+tx,100+ty);
ReleaseDC(pDC);
}
void CGeotranView::Onrotation()
{
// 旋转, 角度sita=30度
CDC *pDC=GetDC();
double sita=30;
double hudu=sita*3.14159/180;
pDC->MoveTo(int(100*cos(hudu)-100*sin(hudu)),