MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Naturally coloring a Voronoi diagram using Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105614] Re: Naturally coloring a Voronoi diagram using Mathematica
  • From: dh <dh at metrohm.com>
  • Date: Fri, 11 Dec 2009 04:18:47 -0500 (EST)
  • References: <hfqglu$oke$1@smc.vnet.net>


Hi Kelly,

you specified your function on a grid: f[i/n,j/n] with 0<=i,j<=n.

You may interpolate this function by "Interpolation":



data=Table[{f[i/n,j/n],i,j},{i,0,n},{j,0,n}];

fun=Interpolation[data];



Here is an example:



n = 10;

f0[i_, j_] := Mod[i + j, 1];

data = Flatten[Table[{i/n, j/n, f0[i/n, j/n]}, {i, 0, n}, {j, 0, n}],

    1];

f1 = Interpolation[data];

Plot3D[0, {i, 0, 1}, {j, 0, 1}, ColorFunction -> (Hue[f1[#1, #2]] &)]

Daniel



Kelly Jones wrote:

> I've defined 0 <= f[x] <= 1 for 1000 x's in the unit square, and now

> want to extend f as a uniformly continuous function on the entire unit

> square as follows:

> 

>  % For any two points x and y in the unit square, and 0<=k<=1:

> 

> f[k*x + (1-k)*y] = k*f[x] + (1-k)*f[y]

> 

> Note that x and y are points in the unit square, not real numbers.

> 

>  % The equation above applies to the 1000 points I originally defined,

>  but also to any two other points in the unit square.

> 

>  % I want to compute f efficiently.

> 

> Essentially, I have a Voronoi diagram and have assigned a different

> hue to each point (but saturation=value=1, so we're only dealing w/

> 1-dimensional color), and now want to color the entire diagram

> efficiently in a "reasonable" way.

> 

> Ideally, I'd like to find a *function* that does this, but if

> Mathematica can do this w/ Graphics (eg, some sort of color

> gradient?), that's fine too.

> 

> I do realize I'm probably limited to coloring the convex hull of my

> original points.

> 

> PS: Thanks to everyone who replies to my other questions. I'm bad

> about replying, but do appreciate the answers and do learn from them.

> 




  • Prev by Date: Re: Re: Manipulate a NDSolve equation is it possible
  • Next by Date: Re: Naturally coloring a Voronoi diagram using Mathematica
  • Previous by thread: Re: Naturally coloring a Voronoi diagram using Mathematica
  • Next by thread: Re: would like to compute a tensor derivative of a function and