日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

矩形重叠检测。

發布時間:2025/7/14 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 矩形重叠检测。 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
// 矩形重疊類型注釋 // CORNER_OVERLAP // -------------------- // | | // | | // | **********|********** // | * | * // | * | * // ---------*---------| * // * * // * * // ********************* // // ANCHOR_OVERLAP // ---- // | | // | | // *******|**|******* // * | | * // * | | * // * ---- * // * * // ****************** // SAME_WIDTH_OVERLAP // |-----------------| // | | // ******************| // |-----------------* // * * // ******************* // // INSIDE_OVERLAP // ********************** // * * // * --------- * // * | | * // * | | * // * --------- * // * * // ********************** // // CROSS_OVERLAP // ----- // | | // | | // *****|***|****** // * | | * // * | | * // *****|***|****** // | | // ----- typedef enum EM_RectOverlapType {NO_OVERLAP,CORNER_OVERLAP,ANCHOR_OVERLAP,SAME_WIDTH_OVERLAP,INSIDE_OVERLAP,CROSS_OVERLAP,ERROR_OVERLAP, }EM_RectOverlapType;//判斷Rect重疊的類型,判定方法 //NO_OVERLAP: 重疊矩形面積為0 //CORNER_OVERLAP: 重疊矩形的一個角的兩條邊,與被判定矩形的一個角的兩條邊坐標一致(角的2條邊) //SAME_WIDTH_OVERLAP: 兩個矩形的橫向坐標或者縱向坐標一致,并且重疊。 //ANCHOR_OVERLAP: 重疊矩形的三條邊與被判定矩形的三條邊重疊(3個邊) //INSIDE_OVERLAP: 重疊矩形與被判定矩形的其中之一完全重合(4個邊) //CROSS_OVERLAP : 重疊矩形的平行的兩條邊與被判定矩形之一的對應兩條邊重疊,另兩條邊與另一個被判定矩形的對應的另兩條邊重疊(2對對應的兩條邊) //后三種的相同部分是都有平行的兩條邊重合,所以判定先重后三行開始 EM_RectOverlapType JudgeOverlapTypeByTwoRect(const EM_RECT& firstRect,const EM_RECT& overlapRect) {if ( (overlapRect.left == firstRect.left) && (overlapRect.right==firstRect.right))//平行2條邊{if ( (overlapRect.top == firstRect.top) )//3條邊{if (overlapRect.bottom == firstRect.bottom)//4條邊{return INSIDE_OVERLAP;}else{return ANCHOR_OVERLAP;}}else if (overlapRect.bottom == firstRect.bottom){if (overlapRect.top == firstRect.top){return INSIDE_OVERLAP;}else{return ANCHOR_OVERLAP;}}else{return SAME_WIDTH_OVERLAP;}}else if ((overlapRect.top == firstRect.top) && (overlapRect.bottom == firstRect.bottom) ){return SAME_WIDTH_OVERLAP;}else {return CORNER_OVERLAP;} }EM_RectOverlapType JudgeOverlapType(const EM_RECT& firstRect,const EM_RECT& secondRect,const EM_RECT& overlapRect) {EM_RectOverlapType firstType = JudgeOverlapTypeByTwoRect(firstRect,overlapRect);if (ERROR_OVERLAP != firstType){ return firstType;}else{EM_RectOverlapType secondType = JudgeOverlapTypeByTwoRect(secondRect,overlapRect); if (ERROR_OVERLAP != secondType){return secondType;}else{return ERROR_OVERLAP;}} }EM_RectOverlapType GetRectOverlapType(const EM_RECT& firstRect,const EM_RECT& secondRect) {EM_RECT overlapRect = GetOverlapRect(firstRect,secondRect);long overlapRectSize = GetEM_RECTSize(overlapRect);if (overlapRectSize){return JudgeOverlapType(firstRect,secondRect,overlapRect);}else{return NO_OVERLAP;} }

  

轉載于:https://www.cnblogs.com/Dennis-mi/p/3812072.html

總結

以上是生活随笔為你收集整理的矩形重叠检测。的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。