CG_MinkowskiSum — 执行 Minkowski sum
geometry CG_MinkowskiSum(
geometry geom1, geometry geom2)
;
此函数执行点、线或多边形与多边形的 2D minkowski 和。
两个几何图形 A 和 B 的minkowski和是所有点的集合,这些点是 A 和 B 中任意点的和。minkowski和经常用于运动规划和计算机辅助设计。 有关更多详细信息在维基百科 Minkowski 添加。
第一个参数可以是任何 2D 几何图形(点、线串、多边形)。 如果传递 3D 几何图形,则会通过强制 Z 为 0 将其转换为 2D,从而可能导致无效的情况。 第二个参数必须是二维多边形。
实现利用 CGAL 2D Minkowskisum。
可用性:3.5.0
该方法需要SFCGAL后端。
Minkowski 线串与圆多边形的总和,其中线串穿过圆
|
|
SELECT CG_MinkowskiSum(line, circle)) FROM (SELECT ST_MakeLine(ST_Point(10, 10),ST_Point(100, 100)) As line, ST_Buffer(ST_GeomFromText('POINT(50 50)'), 30) As circle) As foo; -- wkt -- MULTIPOLYGON(((30 59.9999999999999,30.5764415879031 54.1472903395161,32.2836140246614 48.5194970290472,35.0559116309237 43.3328930094119,38.7867965644036 38.7867965644035,43.332893009412 35.0559116309236,48.5194970290474 32.2836140246614,54.1472903395162 30.5764415879031,60.0000000000001 30,65.8527096604839 30.5764415879031,71.4805029709527 32.2836140246614,76.6671069905881 35.0559116309237,81.2132034355964 38.7867965644036,171.213203435596 128.786796564404,174.944088369076 133.332893009412,177.716385975339 138.519497029047,179.423558412097 144.147290339516,180 150,179.423558412097 155.852709660484,177.716385975339 161.480502970953,174.944088369076 166.667106990588,171.213203435596 171.213203435596,166.667106990588 174.944088369076, 161.480502970953 177.716385975339,155.852709660484 179.423558412097,150 180,144.147290339516 179.423558412097,138.519497029047 177.716385975339,133.332893009412 174.944088369076,128.786796564403 171.213203435596,38.7867965644035 81.2132034355963,35.0559116309236 76.667106990588,32.2836140246614 71.4805029709526,30.5764415879031 65.8527096604838,30 59.9999999999999)))
多边形和多点的 Minkowski 和
|
|
SELECT CG_MinkowskiSum(mp, poly) FROM (SELECT 'MULTIPOINT(25 50,70 25)'::geometry As mp, 'POLYGON((130 150, 20 40, 50 60, 125 100, 130 150))'::geometry As poly ) As foo -- wkt -- MULTIPOLYGON( ((70 115,100 135,175 175,225 225,70 115)), ((120 65,150 85,225 125,275 175,120 65)) )