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

2023-01-15  本文已影响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";
    }
}
上一篇下一篇

猜你喜欢

热点阅读