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:
And if Inkscape can't do this, can anyone suggest an SVG editor that can?
Thanks.
How to derive minimum bounding convex polygon?
Re: How to derive minimum bounding convex polygon?
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.
This seems to be a good material to write an extension that does automatically derive the minimum bounding convex polygon of a path.
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.
Re: How to derive minimum bounding convex polygon?
Thanks L, but I think they have not provided the definition of the function.
Re: How to derive minimum bounding convex polygon?
Hi.
Have a search for; "convex hull python".
http://code.activestate.com/recipes/66527findingtheconvexhullofasetof2dpoints/
http://www.scipy.org/Cookbook/Finding_Convex_Hull
http://en.literateprograms.org/Quickhull_%28Python,_arrays%29
Start Coding  the race is on!
RGDS
Ragnar
Have a search for; "convex hull python".
http://code.activestate.com/recipes/66527findingtheconvexhullofasetof2dpoints/
http://www.scipy.org/Cookbook/Finding_Convex_Hull
http://en.literateprograms.org/Quickhull_%28Python,_arrays%29
Start Coding  the race is on!
RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
Re: How to derive minimum bounding convex polygon?
ragstian wrote:Start Coding  the race is on!
Thanks. I'll camp by the finish line
Re: How to derive minimum bounding convex polygon?
Hi chrisjj
chrisjj wrote;
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)
RGDS
Ragnar
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)
RGDS
Ragnar
 Attachments

 ConvexHull.zip
 (1.98 KiB) Downloaded 222 times
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
Re: How to derive minimum bounding convex polygon?
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').
Re: How to derive minimum bounding convex polygon?
Hi ~suv
~suv wrote;
Working on your suggestion  the learning curve writing extensions is steep!!
Thanks for the feedback  it's appreciated!
RGDS
Ragnar
~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!!
Thanks for the feedback  it's appreciated!
RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
Re: How to derive minimum bounding convex polygon?
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.
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”
Who is online
Users browsing this forum: No registered users and 7 guests