美文网首页
C++判断点是否在轮廓内

C++判断点是否在轮廓内

作者: 会当临绝顶山小 | 来源:发表于2023-01-15 17:31 被阅读0次
    string isPointInRect(int pointx, int pointy, int x, int y, int width, int height)
    {
        if ((pointx < x) || (pointy < y) || 
            (pointx > (x + width)) || (pointy > (y + height))) {
            return "out";
        } else if ((pointx == x) && (pointy >= y && pointy <= y + height) || 
                    (pointy == y) && (pointx >= x && pointx <= width)) {
            return "on";
        } else if ((pointx > x) && (pointy > y) && 
                    (pointx < (x + width)) && (pointy < (y + height))) {
            return "in";
        }
    }
    

    相关文章

      网友评论

          本文标题:C++判断点是否在轮廓内

          本文链接:https://www.haomeiwen.com/subject/mdyacdtx.html