View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Arbitrary Square Bounded Voronoi Diagram

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

3.75
3.8 | 4 ratings Rate this file 5 Downloads (last 30 days) File Size: 8.7 KB File ID: #30353 Version: 1.0
image thumbnail

Arbitrary Square Bounded Voronoi Diagram

by

 

Compute individual Voronoi cell area of 2D point sets bounded in an arbitrary square

| Watch this File

File Information
Description

This function compute the individual Voronoi cell area of point sets bounded in an arbitrary square.

Inputs:
x : M x 1 array of x-coordinates
y : M x 1 array of y-coordinates
toggleplot : 1 to turn on figures, 0 to turn off figures;
[x1,x2,y1,y2] : 1 x 4 array of square edges

Outputs:
CellArea : M x 1 array of Voronoi cell area bounded in an arbitrary square

Usage:
CellArea=SquareBV(x,y,toggleplot,[x1,x2,y1,y2])
CellArea=SquareBV(x,y,toggleplot)

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
07 Sep 2016 Ignacio Bordeu

Sorry, wrong file.

Comment only
07 Sep 2016 Ignacio Bordeu

Hey guys, I have found an issue when considering certain sets of points. When trying the following example:

xc = [25.0362, 619.2890, 137.8061, 387.3650, 2.7294, 85.5450]

yc = [643.6328, 8.6653, 621.3243, 55.4894, 545.6431, 193.8842]

r = 500;
VoronoiLimit(xc,yc,'bs_ext',[0,r;r,r;r,0;0,0],'figure','on');

You can see that the limits are not drawn correctly, this issue disappears for smaller values of r.. any ideas on how to fix it?

Comment only
20 Mar 2016 Juan Nogues

I am getting the following error:
Error using qhullmx
QH6019 qhull input error: can not scale last coordinate. Input is cocircular
or cospherical. Use option 'Qz' to add a point at infinity.

My command line looks something like this

>> x1=-10;
>> x2=10;
>> y1=-10;
>> y2=10;
>> x=[-5 5 5 -5]';
>> y=[-5 -5 5 5]';
>> CellArea=SquareBV(x',y',1);

Any help on this ?

Comment only
09 Oct 2014 Charles

I only used it for a very simple rectangle bounding an area with four "precipitation gage" points, but it worked well. The figures come out looking odd and confusing, but the calculation of areas, which is the basic point, was correct. Thanks!

16 May 2014 Tom

Tom (view profile)

By a "partial solution," what did Simon mean (on 15 Feb 2012)?

After I edit SquareBV line 66 to add the qhull option QJ, SquareBV now runs, but reports an (incorrect) area of zero for each of four Voronoi cells.

Any ideas on how to fix this?

Comment only
27 Mar 2014 Dikun

Dikun (view profile)

I think I have found in some cases this code doesn't work properly.

Try examples:

SquareBV([56.01 188.01 47.01],[6 9 4],0,[-450 450 -750 750])

or

SquareBV([56.01 188.01 47.01],[6 9 4],0,[-450 450 0 750])

PS: toggleplot=1 doesn't plot sensible figures.

15 Feb 2012 Simon Arame

I found a partial solution to my enquiry, voronoin has to be called with the option 'QJ'

Comment only
15 Feb 2012 Simon Arame

Greetings,

This file is great, however there seem to be a problem with colinear points. I got an error message while testing for :
x = [0.25; 0.75; 0.25; 0.75];
y = [0.25; 0.25; 0.75; 0.75];
SquareBV(x,y,0,[0,1,0,1])

Comment only
07 Feb 2012 Meng Sang Ong

Hi Oscar,
Thank you for your comment.
To answer your question, the function aims to compute the individual Voronoi cell area of point sets BOUNDED in an arbitrary square.

However, from your inputs, you have a x-input (5.0000,5.0000) which lies outside of your square boundary [0 1 0 1], hence will result in incorrect cell area computation.

You can either opt to have all your x and y points inside the square [0 1 0 1] or introduce a larger boundary, e.g. [0 5 0 5], so that it encapsulates your third point (5.0000, 5.0000).

Hope it helps.

Comment only
18 Aug 2011 Oscar

Oscar (view profile)

It seems this function has some bugs in it. With input
x = 0.5000 y= 0.3333
0.5010 0.6666
5.0000 5.0000

and corners = [0 1 0 1] it gives me [4997 0 0]. This, clearly is not correct, as the two first points should have roughly half each of the specified area. Or perhaps I don't understand the interface correctly. Also, the documentation is rather sparse for this code. Thanks, though for a great effort. This is the only code I could find that attempts this.

21 Jul 2011 Egor Bogatinskiy  

Contact us