aihot  2017-05-08 23:50:46  OpenCV |   查看评论   
    float xSquare2=x+dist;  
  •     float ySquare1=y-dist;  
  •     float ySquare2=y+dist;  
  •       
  •     if(xSquare1<=x2&&xSquare2>=x1&&ySquare1<=y1&&ySquare2>=y2){      
  •         return 1;  
  •     }  
  •     //check whether there is a vertex of the rectangle in the circle  
  •     //center of rectangle  
  •     float xrectangle=(x1+x2)/2;  
  •     float yrectangle=(y1+y2)/2;  
  •     //rectangle is on the top left side of circle  
  •     if(xrectangle<=x&&yrectangle<=y&&  
  •         sqrt((x2-x)*(x2-x)+(y2-y)*(y2-y))<=r)  
  •         return 1;  
  •     else if(xrectangle>x&&yrectangle<=y&&  
  •         sqrt((x1-x)*(x1-x)+(y2-y)*(y2-y))<=r)  
  •         return
  •  

    除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自矩形和圆的相交检测 算法分析与实现

    留言与评论(共有 0 条评论)
       
    验证码:
    [lianlun]1[/lianlun]