请大神帮忙翻译一下,下面内容C++坐标转换的算法
x坐标,y坐标,是如何计算出来的
sprintf(ch_watchax,"%f",f_watchax);
i_watchax=_ttoi(ch_watchax);
sprintf(ch_watchay,"%f",f_watchay);
i_watchay=_ttoi(ch_watchay);
sprintf(ch_watchx,"%f",f_watchx);
i_watchx=_ttoi(ch_watchx);
sprintf(ch_watchy,"%f",f_watchy);
i_watchy=_ttoi(ch_watchy);
// if(bgchangey==0)bgchangey=j_
realx=i_watchx-(int)i_watchax/2;
allx=realx+i_watchax;
ally=i_watchy+i_watchay;
if (x>realx&&x<allx)//判断坐标
{
if (y>i_watchy&&y<ally)
{
//坐标转换测试 大-屏幕
//GetPrivateProfileStringA("try","x","",ch_tryx,8,"C:\\test.ini");//读取对应信息
// GetPrivateProfileStringA("try","y","",ch_tryy,8,"C:\\test.ini");//读取对应信息
// f_tryx=atof(ch_tryx);
// f_tryy=atof(ch_tryy);
rx=x-realx;
l123=1.000*re_main.right/f_watchax*0.94*rx;
ry=y-i_watchy;
// sprintf(basey,"%d",re_main.top);
sprintf(ch_bghp,"%d",myHp[many]);
//i_watchay+=650;
l321=1.000*re_main.bottom/f_watchay*1.06*ry;
i_gogoy=re_main.bottom-l321+6;
if(i_model==2)i_gogoy+=40;
DrawMyText123(pDxdevice,ch_id[many],sizeof ch_id[many],l123,i_gogoy,f_id,2);
DrawMyText123(pDxdevice,ch_forhp,2,l123+60,i_gogoy,f_id,2);
if ((int)strlen(ch_bghp)>0)
{
DrawMyText123(pDxdevice,ch_bghp,(int)strlen(ch_bghp),l123+92,i_gogoy,f_id,1);//hp
}
DrawMyText123(pDxdevice,ch_xian, (int)strlen(ch_xian),l123,i_gogoy+3,f_id,2);
}
}
}
|