| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 386 人关注过本帖
标题:这段程序原理算法是什么
只看楼主 加入收藏
shijidaqiao
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-5-25
结帖率:100%
收藏
 问题点数:0 回复次数:0 
这段程序原理算法是什么
    nt CMy1View::drawPoint(float m, float n, float k)
{
    int a=30,b=105;  
    double Z,A,x,y;
    int x0,y0;

    Z=acos(sin(m*Pi/180)*sin(a*Pi/180)+cos(m*Pi/180)*cos(a*Pi/180)*cos(n*Pi/180-b*Pi/180));
    if(sin(Z)==0)A=0;
    else A=asin(cos(m*Pi/180)*sin(n*Pi/180-b*Pi/180)/sin(Z));
    if(m<a)x=-(R*Z*cos(A))/BLC;
    else x=R*Z*cos(A)/BLC;
    y=R*Z*sin(A)/BLC;

    if(m==25&&(n==55||n==145))  x=-x;
    if(k==0)return y0=int(zy-1000*x);
    if(k==1)return x0=int(1000*y+sx);
}

void CMy1View::LineClip(float x1, float y1, float x2, float y2)
{
    CDC *pDC=GetDC();
    GetCurrentPen();
    CPen pen;
    pen.CreatePen(i,j,RGB(0,0,0));
    pDC->SelectObject(pen);
    float dx,dy,u1,u2;
    XL=drawPoint(12,80,1);
    XR=drawPoint(55,144,1);
    YT=drawPoint(12,80,0);
    YB=drawPoint(55,144,0);
    u1=0;
    u2=1;
    dx=x2-x1;
    dy=y2-y1;
    if(Clip(-dx,x1-XL,&u1,&u2))
      if(Clip(dx,XR-x1,&u1,&u2))
        if(Clip(-dy,y1-YB,&u1,&u2))
          if(Clip(dy,YT-y1,&u1,&u2))
           {
              pDC->MoveTo(x1+u1*dx,y1+u1*dy);
              pDC->LineTo(x1+u2*dx,y1+u2*dy);
           }
           ReleaseDC(pDC);
}

bool CMy1View::Clip(float p, float q, float *u1, float *u2)
{
    float r;
    if(p<0)
    {
       r=q/p;  
       if(r>*u2)
       return false;
     if(r>*u1)
       *u1=r;
    }
     else if(p>0)
     {
            r=q/p;
         if(r<*u1)
             return false;
            if(r<*u2)
            *u2=r;
     }
     else return (q>=0);
        return true;
}
搜索更多相关主题的帖子: return 
2011-06-07 15:36
快速回复:这段程序原理算法是什么
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011137 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved