help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Voronoi Diagrams


From: David Bateman
Subject: Re: Voronoi Diagrams
Date: Mon, 22 Dec 2008 22:23:13 +0100
User-agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018)

Ben Abbott wrote:
On Dec 22, 2008, at 1:43 PM, Søren Hauberg wrote:

man, 22 12 2008 kl. 13:25 -0500, skrev Ben Abbott:
        ll = min (length (idx), length (c));
Isn't that the same as

 ll = length (c);

?

Søren


In this case yes. But I don't understand what the line below is accounting for.

        idx = find (!infi);

Ben

I suspect the issue is my fault and not Kai's ... When importing this code from octave-forge into Octave I tried to make it fully matlab compatible. Matlab draws lines in the Voronoi diagram with vertices at infinite, whereas the original octave-forge code didn't.. The get this behavior I added a big box around the vertices to simulate vertices at infinite, and then flagged the tesselations with a vertex at infinite with the third return argument of __voronoi__.. However I sized this return argument differently than the second return argument.. I suspect the attached is a better solution to the issue, though your proposed fix comes to much the same thing.. My patch tries to be a bit faster as it avoid multiple resizes of one of the return arrays as well.

D.



--
David Bateman                                address@hidden
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)

# HG changeset patch
# User David Bateman <address@hidden>
# Date 1229980587 -3600
# Node ID 9802e81c317a0772404ff54ea0a16e91b7f7d9f7
# Parent  777fcb8a9da08541a3043dc489faae326c239880
Reszie third arg of __voronoi__ before retuning it

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-12-22  David Bateman  <address@hidden>
+
+       * DLD-FUNCTIONS/__voronoi__.cc (F__voronoi__): Resize AtInf array
+       before returning it.
+
 2008-12-12  David Bateman  <address@hidden>
 
        * DLD-FUNCTIONS/chol.cc (Fcholinv): Add test.
diff --git a/src/DLD-FUNCTIONS/__voronoi__.cc b/src/DLD-FUNCTIONS/__voronoi__.cc
--- a/src/DLD-FUNCTIONS/__voronoi__.cc
+++ b/src/DLD-FUNCTIONS/__voronoi__.cc
@@ -165,7 +165,7 @@
       boolMatrix AtInf (np, 1);
       for (i = 0; i < np; i++) 
        AtInf(i) = false;
-      octave_value_list F;
+      octave_value_list F (np, octave_value ());
       k = 0;
       i = 0;
 
@@ -220,6 +220,7 @@
 
       retval(0) = v;
       retval(1) = C;
+      AtInf.resize (r, 1);
       retval(2) = AtInf;
 
       // free long memory

reply via email to

[Prev in Thread] Current Thread [Next in Thread]