POV-Ray : Newsgroups : povray.binaries.images : voronoi cell Server Time
25 Dec 2024 20:28:42 EST (-0500)
  voronoi cell (Message 1 to 7 of 7)  
From: ingo
Subject: voronoi cell
Date: 11 Feb 2019 05:10:21
Message: <XnsA9F371A6F4BB9seed7@news.povray.org>
For creating a voronoi cell we need nearest neighbours. The simplest way 
to create those is with creating random points on a sphere. For 
constructing a cell that's all that's needed.
top left: intersection of planes
rop right: intersection of isosurface planes
bottom left: noisy isosurface version
bottom right: blob

ingo

---%<------%<------%<---

#include "transforms.inc"

camera {
  perspective angle 11
  location  <0,0,-25>
  look_at   <0,0,  0>
}
light_source{< -300, 3000,   0> rgb <0.3,0.3,0.2>}
light_source{< 3000,  300,-500> rgb .5}
light_source{<  300,-3000,   0> rgb <0.2,0.2,0.4>}

#declare Point = <0,0,0>;
#declare Stream = seed(12);
#declare N=33;
#declare arrNeighbours = array[N];
#for(I,0,N-1)
  #declare arrNeighbours[I] = VRand_On_Sphere(Stream)/2;
#end

intersection{
  #for(I,0,N-1)
    #declare Neighbour=arrNeighbours[I];
    #declare Distance = vlength(Neighbour);
    #declare Normal = vnormalize(Neighbour);
    plane{Normal, Distance pigment{rgb 1}}
  #end 
  translate <-1,1,0>
}

#declare fnNeighbours = array[N];
#for(I,0,N-1)
  #declare Neighbour = arrNeighbours[I];
  #declare Distance = vlength(Neighbour);
  #declare Normal = vnormalize(Neighbour);
  #declare nX = Normal.x;
  #declare nY = Normal.y;
  #declare nZ = Normal.z;
  #declare fnNeighbours[I]=function{(nX*x+nY*y+nZ*z)-Distance};
#end

#declare fnIntersection = function{
  max(
    #for(I,0,N-1,1)
      #if(I>0)
        , fnNeighbours[I](x,y,z)
      #else
        fnNeighbours[I](x,y,z)
      #end
    #end
  )
}

isosurface {
  function{
    fnIntersection(x,y,z)
  }
  contained_by {sphere{0,1.5}}
  max_gradient 2
  pigment{rgb 1}
  translate <1,1,0>
}

isosurface {
  function{
    fnIntersection(x,y,z)-(f_noise3d(x*10, y*10, z*10)*0.1)
  }
  contained_by {sphere{0,1.5}}
  max_gradient 2
  pigment{rgb 1}
  translate <-1,-1,0>
}

blob{
  threshold .40
  sphere{Point,1,1}
  #for(I,0,N-1)
    #declare Neighbour = arrNeighbours[I];
    #declare Distance = vlength(Neighbour);
    #declare Normal = vnormalize(Neighbour);
    sphere{0,1,-0.1 scale <1,0.1,1> Point_At_Trans(Normal) translate 
Normal*Distance}    
  #end
  pigment{rgb 1}
  translate<1,-1,0>
}

#for(I,0,N-1,1)
  sphere{arrNeighbours[I],0.01 pigment{rgb x} translate<-1, 1,0>}
  sphere{arrNeighbours[I],0.01 pigment{rgb x} translate< 1,-1,0>}
  sphere{arrNeighbours[I],0.01 pigment{rgb x} translate< 1, 1,0>}
#end


Post a reply to this message


Attachments:
Download 'voro.png' (93 KB)

Preview of image 'voro.png'
voro.png


 

From: clipka
Subject: Re: voronoi cell
Date: 11 Feb 2019 13:09:04
Message: <5c61ba40@news.povray.org>
Am 11.02.2019 um 11:10 schrieb ingo:
> For creating a voronoi cell we need nearest neighbours. The simplest way
> to create those is with creating random points on a sphere.

Note that limiting your neighbor points to a sphere surface will create 
a special case of voronoi cell, in which all surfaces are touching an 
inscribed sphere.

For a more generalized case, use random points _in_ a sphere.

(Also, simply using radom points comes with a non-zero probability that 
the cell will be "open" because all neighbors happen to occupy the same 
hemisphere.)


Post a reply to this message

From: ingo
Subject: Re: voronoi cell
Date: 11 Feb 2019 13:55:35
Message: <XnsA9F3CAB443AD6seed7@news.povray.org>
in news:5c61ba40@news.povray.org clipka wrote:

> Note that limiting your neighbor points to a sphere surface will create 
> a special case of voronoi cell, in which all surfaces are touching an 
> inscribed sphere.

as can be easily visualised by using some 500 points, approximating this 
sphere. 

> For a more generalized case, use random points _in_ a sphere.

Not tried that yet, was using on sphere to have some control over the size 
of the result, it reduces the shapes variation though. Tried random on a 
few ellipsiods, resulting in tiny objects. Maybe a cylindrical object?
 
> (Also, simply using radom points comes with a non-zero probability that 
> the cell will be "open" because all neighbors happen to occupy the same 
> hemisphere.)

Yep, that happens. 

ingo


Post a reply to this message

From: clipka
Subject: Re: voronoi cell
Date: 11 Feb 2019 14:13:21
Message: <5c61c951$1@news.povray.org>
Am 11.02.2019 um 19:55 schrieb ingo:

>> For a more generalized case, use random points _in_ a sphere.
> 
> Not tried that yet, was using on sphere to have some control over the size
> of the result, it reduces the shapes variation though.

Maybe discard points that get too close for comfort?


Post a reply to this message

From: ingo
Subject: Re: voronoi cell
Date: 11 Feb 2019 14:19:18
Message: <XnsA9F3CEB9010F9seed7@news.povray.org>
in news:5c61c951$1@news.povray.org clipka wrote:

> Maybe discard points that get too close for comfort?
> 

and before you know you are generating points on a smaller sphere. But 
yes, given a certain range that works.
It is kind of adding a 'weight' to a point on a sphere. Depending on the 
weight the plane moves more or less towards the centre.

ingo


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: voronoi cell
Date: 12 Feb 2019 09:05:00
Message: <web.5c62d1bbdd3f723751148b5b0@news.povray.org>
Now this is starting to become really interesting Ingo !

--
Tor Olav
http://subcube.com


Post a reply to this message

From: William F Pokorny
Subject: Re: voronoi cell
Date: 12 Feb 2019 09:38:30
Message: <5c62da66$1@news.povray.org>
On 2/12/19 9:02 AM, Tor Olav Kristensen wrote:
> Now this is starting to become really interesting Ingo !
> 
> --
> Tor Olav
> http://subcube.com
> 
> 

Agree. I like this idea/approach to creating shapes. If only more time 
to play...

Really need to get back to creating images for fun for a while. Getting 
burned out on the internal code stuff...

Bill P.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.