123456789101112131415161718192021222324252627282930313233343536 |
- //
- // BoostGeometryTools.hpp
- // auto_fill_jewel_v3
- //
- // Created by Red on 2024/11/26.
- // 几何计算的相关代码。
- #ifndef BoostGeometryTools_hpp
- #define BoostGeometryTools_hpp
- #include <stdio.h>
- #include <boost/geometry.hpp>
- #include <boost/geometry/geometries/point_xy.hpp>
- #include <boost/geometry/geometries/polygon.hpp>
- struct BoostGeometryTools {
- typedef boost::geometry::model::point<float,2,boost::geometry::cs::cartesian> BoostPoint;//定义点
- typedef boost::geometry::model::polygon<BoostPoint,false,false> BoostPolygon;//定义多边形
- typedef boost::geometry::model::box<BoostPoint> BoostBox;
-
- static bool isAIntersectsB(BoostPolygon& polyA, BoostPolygon& polyB);//检验多边形A和B是否相交
- static bool isAWithinB(BoostPolygon& polyA, BoostPolygon& polyB) ;// 测试 A 在 B 的内部
-
- static BoostPolygon makeBox( float lowerLeftX,float lowerLeftY,float wid,float hei ) ;
- static BoostPolygon makeRotatedBox( float lowerLeftX,float lowerLeftY,float wid,float hei,float rotdeg) ;//绕0,0点旋转
- static BoostPolygon makeRotateNTranslateBox( float lowerLeftX,float lowerLeftY,float wid,float hei,float rotdeg,float dx,float dy) ;//先绕0,0点旋转,然后平移dx和dy
- static void rotatePoint( float x0, float y0, float rotRad, float& x1,float& y1) ;//围绕0,0点旋转一个点,rotRad使用弧度
- static BoostPolygon translatePolygon(BoostPolygon& poly,float dx,float dy) ;//平移一个多边形
- static BoostPolygon convex_hull(BoostPolygon& poly) ;//计算外接包裹盒子多边形
- static bool pointIntersetsBox(BoostPoint& ptA,BoostPolygon& polyB) ;//检验点是否在多边形内部
- } ;
- #endif /* BoostGeometryTools_hpp */
|