Boost::geometry Polygon operations (C++)
Overview
C++ Code for Polygon operation with Boost geometry library
Introduction
Boost Geometry is part of collection of the Boost C++ libs, defines concepts, primitives and algorithms for solving geometry problems ref.
Polygon is a planar surface defined by one exterior boundary and zero or more interior boundaries ref.
Polygon operation is often used in robotics industry's perception systems, particularly for tasks such as defining safety zones and obstacle bounding boxes. Some common applications include:
- Calculation the overlapping proportion between obstacle bounding box and safety zone, to determine the danger level.
- Verifying if an obstacle enters the danger zone of an ego vehicle.
- Determining if some LiDAR points reside within a specified zone.
Applications
- Generate Random Polygons: Create two random polygons.
- Validity Check and Area Calculation: Verify the validity of the polygons and calculate their areas.
- Intersection Detection: Determine if the two polygons intersect and compute the intersection polygon if they do.
- Point Inclusion Check: Check if a specified point lies within the intersection polygon.
Example output:
1Polygon is invalid, retrying...
2Polygon is invalid, retrying...
3Polygon 1 points are: (1.05432, 2.2592) (1.5928, 3.05599) (2.93741, 2.09024) (1.47085, 0.798034) (1.05432, 2.2592) Area is: 2.13627
4Polygon is invalid, retrying...
5Polygon is invalid, retrying...
6Polygon is invalid, retrying...
7Polygon 2 points are: (1.97136, 2.36949) (2.81913, 0.603898) (1.81515, 1.29083) (0.327355, 3.53608) (1.97136, 2.36949) Area is: 1.5729
8Polygon intersect points are: (1.11448, 2.34822) (1.40193, 2.77356) (1.97136, 2.36949) (2.35279, 1.57512) (1.93617, 1.20803) (1.81515, 1.29083) (1.11448, 2.34822) Area is: 0.946869
9origin is outside the polygon
comments powered by Disqus