我在用vc6.0++mfc工程做图形学,这个相对任意点错切的函数,实现时并没有相对某个点移动,还是在原来的位置,不知道哪里写错了
void CTestView::OnSharex() //任意点错切
{
// TODO: Add your command handler code here
CDC *pDC = GetDC();
CRect rectClient;
GetClientRect(rectClient);
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(2000,1000);
pDC->SetViewportExt(rectClient.right,-rectClient.bottom);
pDC->SetViewportOrg(rectClient.right/2,rectClient.bottom/2);
CPen MyPen,*OldPen;
int color = RGB(0,0,255);
MyPen.CreatePen(PS_SOLID,3,color);
OldPen=pDC->SelectObject(&MyPen);
double b,c;
DialogShare dlg;
if(dlg.DoModal())
{
b = dlg.m_b;
c = dlg.m_c;
}
int x,y;
DialogX dlg1;
if(dlg1.DoModal())
{
x = dlg1.m_x*100;
y = dlg1.m_y*100;
}
int i,t[6];
for(i=0;i<6;i++)
{
if(i%2 == 0)
{
t[i] = n[i] + c*n[i+1]-y*c;
}
else
{
t[i] = b*n[i-1] + n[i]-b*x;
}
}
double tx,ty;
tx = ((n[0] + n[2] + n[4]) - (t[0] + t[2] + t[4]))/3;
ty = ((n[1] + n[3] + n[5]) - (t[1] + t[3] + t[5]))/3;
Tri(t[0]+tx,t[1]+ty,t[2]+tx,t[3]+ty,t[4]+tx,t[5]+ty,pDC);
}