学习心得(code)

superlong@CoreCoder

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  74 Posts :: 0 Stories :: 5 Comments :: 0 Trackbacks

公告

文字可能放在http://blog.csdn.net/superlong100,此处存放代码

常用链接

留言簿(4)

我参与的团队

搜索

  •  

最新随笔

最新评论

  • 1. re: Poj 1279
  • 对于一个凹多边形用叉积计算面积 后能根据结果的正负来判断给的点集的时针方向?
  • --bsshanghai
  • 2. re: Poj 3691
  • 你写的这个get_fail() 好像并是真正的get_fail,也是说fail指向的串并不是当前结点的子串。为什么要这样弄呢?
  • --acmer1183
  • 3. re: HDU2295[未登录]
  • 这个是IDA* 也就是迭代加深@ylfdrib
  • --superlong
  • 4. re: HDU2295
  • 评论内容较长,点击标题查看
  • --ylfdrib
  • 5. re: HOJ 11482
  • 呵呵..把代码发在这里很不错..以后我也试试...百度的编辑器太烂了....
  • --csuft1

阅读排行榜

评论排行榜

 
#include <stdio.h>
#include 
<math.h>
#define eps 1e-10

int sig( double x )
{
    
return (x>eps) - (x<-eps);
}

double dis(double x1,double y1,double x2,double y2)
{
    
return sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) );
}

double angle(double x, double y)
{
    
return atan2(y , x);
}

int main()
{
    
double x1, y1, r1, x2, y2, r2;
    
double d1, d2, l1, l2; // l1 l2切线  d1 d2 切线的夹角 
    double dis1, dis2;     // 圆心到原点的距离 
    double ag1, ag2;       // 圆心的极角 
    double d, ag;          // d圆心与原点的夹角 ag平分线与切线的角度 
    double ans;
    
while(scanf("%lf %lf %lf"&x1, &y1, &r1) != EOF)
    {
        scanf(
"%lf %lf %lf"&x2, &y2, &r2);
        
        dis1 
= dis(x1, y1, 00);
        dis2 
= dis(x2, y2, 00);
        
        
if(sig(dis1 - r1) <= 0 || sig(dis2 - r2) <= 0)
        {
            puts(
"center covered");
            
continue;
        }
        
        l1 
= sqrt(dis1 * dis1 - r1 * r1);
        l2 
= sqrt(dis2 * dis2 - r2 * r2); // 勾股定理 
        
        d1 
= asin( r1 / dis1 );
        d2 
= asin( r2 / dis2 );
        d 
= acos( ( x1 * x2 + y1 * y2) / (dis1 * dis2) );
        
//余弦定理 
        
        
if( sig(d - d1 - d2) <= 0 ) 
        {
            puts(
"no slice between them");
            
continue;
        }        
        ag 
=( d - d1 - d2 ) / 2;        
        ag1 
= angle(x1 , y1);
        ag2 
= angle(x2 , y2);
                
        
if(sig(fabs(ag1 - ag2) - M_PI) <= 0)
        {
            ans 
= sig(ag1 - ag2) < 0 ? ag1 + d1 + ag : ag2 + d2 + ag;
        }
        
else
        {
            ans 
= sig(ag1 - ag2) > 0 ? ag1 + d1 + ag : ag2 + d2 + ag;
        }
        
        
if( sig(ans - M_PI / 2> 0) ans -= M_PI;
        
if( sig(ans + M_PI / 2< 0) ans += M_PI;
        
        printf(
"slice at %.2lf degrees\n",ans / M_PI * 180);
    }
}

posted on 2009-08-06 00:49 superlong 阅读(115) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理