How to derive minimum bounding convex polygon?

Post questions on how to use or achieve an effect in Inkscape.
chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

How to derive minimum bounding convex polygon?

Postby chrisjj » Tue Mar 05, 2013 11:00 pm

How may I automatically derive the minimum bounding convex polygon of an object?

E.g. the transparent blue object derived from the red object underneath, here:

Image

And if Inkscape can't do this, can anyone suggest an SVG editor that can?

Thanks.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: How to derive minimum bounding convex polygon?

Postby Lazur » Wed Mar 06, 2013 3:07 am

I was about to say that I don't know about any automatic way, but searching the "minimum bounding convex polygon of an object" of your question pointed here:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000003q000000
where they posted python sources for that function of their business map program.

Code: Select all

# Name: MinimumBoundingGeometry.py
# Description: Use MinimumBoundingGeometry function to find an area
#              for each multipoint input feature.
# Author: ESRI

# import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data"

# Create variables for the input and output feature classes
inFeatures = "treeclusters.shp"
outFeatureClass = "forests.shp"

# Use MinimumBoundingGeometry function to get a convex hull area
#         for each cluster of trees which are multipoint features
arcpy.MinimumBoundingGeometry_management(inFeatures, outFeatureClass,
                                         "CONVEX_HULL", "NONE")


This seems to be a good material to write an extension that does automatically derive the minimum bounding convex polygon of a path.

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: How to derive minimum bounding convex polygon?

Postby chrisjj » Wed Mar 06, 2013 3:22 am

Thanks L, but I think they have not provided the definition of the function.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: How to derive minimum bounding convex polygon?

Postby ragstian » Wed Mar 06, 2013 7:09 am

Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: How to derive minimum bounding convex polygon?

Postby chrisjj » Wed Mar 06, 2013 7:39 am

ragstian wrote:Start Coding - the race is on!


Thanks. I'll camp by the finish line :)

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: How to derive minimum bounding convex polygon?

Postby ragstian » Thu Mar 07, 2013 6:24 am

Hi chrisjj

chrisjj wrote;
ragstian wrote:
Start Coding - the race is on!


Thanks. I'll camp by the finish line :)

Still camping? :)

Here are version 0.01 of my ConvexHull extension;
See atthed file; ConvexHull.zip
(Download the file and Unzip to inkscape/share/extension folder.)
The code is mostly "lifted" from other extensions -
(ExportXY - by Simarilius on this forum - and Eggbot Twist - by Daniel C. Newman).
Python Q_hull routine from here; https://github.com/flengyel/REST/blob/master/quickhull.py

Objects has to be paths, does not yet work on groups. Only path nodes are taken into consideration - will not work on circle outlines etc.
The returned object is simple with a stroke of one pixel and no fill.

Yellow + Pink --> Convex hull = Blue
(Blue fill added for clarity)
Image

RGDS
Ragnar
Attachments
ConvexHull.zip
(1.98 KiB) Downloaded 278 times
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: How to derive minimum bounding convex polygon?

Postby ~suv » Thu Mar 07, 2013 8:01 pm

ragstian wrote:Objects has to be paths, does not yet work on groups. Only path nodes are taken into consideration - will not work on circle outlines etc.
The returned object is simple with a stroke of one pixel and no fill.

Nice :-)

A bonus feature would be to insert the resulting convex hull path into the current layer (append to current group (may be a layer or a regular group), or to the parent group (layer or regular) of the last selected object (in stack order)) - currently the path is generated outside the layer structure (in 'root').

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: How to derive minimum bounding convex polygon?

Postby ragstian » Fri Mar 08, 2013 4:13 am

Hi ~suv

~suv wrote;
A bonus feature would be to insert the resulting convex hull path into the current layer
(append to current group (may be a layer or a regular group), or to the parent group (layer or regular)
of the last selected object (in stack order)) - currently the path is generated outside the layer structure (in 'root').

Working on your suggestion - the learning curve writing extensions is steep!! :D
Thanks for the feedback - it's appreciated!

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: How to derive minimum bounding convex polygon?

Postby chrisjj » Wed Mar 20, 2013 4:32 am

Excellent - thanks Ragnar. It is working well here.

I neat addition would be the option to work separately on selected paths i.e. 1:1 . Then I could do 100 objects separately in one operation.


Return to “Help with using Inkscape”