Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have set of points:

pts={{1.25, 9.75}, {2.5, 9.75}, {2.5, 9.25}, {4, 9.7}, {4, 9.2}, {4, 
  8.75}, {4, 8.25}, {5.5, 9.7}, {5.5, 9.1}, {5.5, 8.5}, {5.5, 
  8.0}, {5.5, 7.5}, {7, 9.8}, {7, 9.2}, {7, 8.75}, {7, 8.1}, {7, 
  7.6}, {9, 9.6}, {9, 9.1}, {9, 8.75}, {9, 8.2}, {9, 7.75}, {11, 
  9.8}, {11, 9.2}, {11, 8.75}, {13, 9.25}, {13, 9.72}};
ListPlot[pts]

and a bounding line:

x = {0, 2.5, 5, 10, 15};
y = {10, 8.27, 7, 7.5, 10};
b=Transpose[{x,y}];
ListLinePlot[b]

How to create a bounded diagram plot? When I use:

Needs["ComputationalGeometry`"]
BoundedDiagram[b, pts]

I get a lot of errors like:

Part::partw: Part 1 of {} does not exist. >>
Part::partw: Part 1 of {} does not exist. >>
Part::pspec: Part specification {}[[1,2]] is neither a machine-sized integer nor a list of machine-sized integers. >>
Part::pspec: Part specification {}[[1,2]] is neither a machine-sized integer nor a list of machine-sized integers. >>

Which don't really let me understand why it doesn't work.

Voronoi diagram, convex hull or delaunay triangulation works just perfect on these points.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I think your choice of boundary polygon is giving BoundedDiagram trouble because it doesn't put each of its vertices in a unique Voronoi cell. I chose a polygon that fit more slackly about your data points and got a nice bounded Voronoi diagram.

Here is a plot showing how your boundary polygon and mine lie in relation to the data points. Your boundary polygon is shown in red.

Needs["ComputationalGeometry`"]
pts =
  {{1.25, 9.75}, {2.5, 9.75}, {2.5, 9.25}, {4, 9.7}, {4, 9.2}, {4,8.75},
   {4, 8.25}, {5.5, 9.7}, {5.5, 9.1}, {5.5, 8.5}, {5.5,8.0},
   {5.5, 7.5}, {7, 9.8}, {7, 9.2}, {7, 8.75}, {7, 8.1}, {7,7.6},
   {9, 9.6}, {9, 9.1}, {9, 8.75}, {9, 8.2}, {9, 7.75}, {11,9.8},
   {11, 9.2}, {11, 8.75}, {13, 9.25}, {13, 9.72}};
tightPts = Transpose[{{0, 2.5, 5, 10, 15}, {10, 8.27, 7, 7.5, 10}}];
slackPts = {{0, 10.5}, {5, 5}, {15, 6}, {16, 11}};
Graphics[{
  {PointSize[Medium], Point[pts]},
  {FaceForm[None], EdgeForm[Black], Polygon @ slackPts, EdgeForm[Red], Polygon @ tightPts}},
  Frame -> True]

data-plot

Using my choice of boundary polygon, I get the following

bd = BoundedDiagram[slackPts, pts];
Show[DiagramPlot[pts, Sequence @@ bd], PlotRangePadding -> {Automatic, {-5, -5}}]

bounded-diagram

You can see from my bounded Voronoi diagram that my boundary polygon could be adjusted to fit more tightly and still maintain its vertices in the separate cells numbered 1, 12, 26 and 27. I leave that adjustment, should you want it, to you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.