POV-Ray : Newsgroups : povray.general : Anybody know this site? Server Time
9 Aug 2024 15:25:39 EDT (-0400)
  Anybody know this site? (Message 6 to 15 of 25)  
<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Chris Huff
Subject: Re: Anybody know this site?
Date: 12 Aug 2000 11:36:45
Message: <chrishuff-3B5DCE.10375112082000@news.povray.org>
In article <39954523.5752D334@kivisalo.net>, Kari Kivisalo 
<kar### [at] kivisalonet> wrote:

> I like to think this as a simple electrical potential, so it can
> be extented to 3d. Time and memory consumption would be too high
> with the iterative method currently used. FFT would be more efficient
> way to solve the potential field. I have to think about this :)
> 
> Just as in 2d the input and solution would be discrete. In 3d
> that would be discrete volumes of densities. I can see this
> had media applications but not sure if it can be used for surface
> generation, maybe with isosurface functions.

This looks like it could be a useful enhancement for the proximity 
pattern(it could solve the grainyness problem)...or something to be 
applied to any pattern. Could you give more details on how you calculate 
it? I didn't see an in-depth explanation on the site.

-- 
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/


Post a reply to this message

From: Kari Kivisalo
Subject: Re: Anybody know this site?
Date: 12 Aug 2000 12:49:12
Message: <3995801A.AC206C81@kivisalo.net>
Chris Huff wrote:
>
> Could you give more details on how you calculate
> it? I didn't see an in-depth explanation on the site.

Here is the theory on 2d electrical potential and how to obtain numerical
approximation using difference equations and iterations. This can be solved
with FFT also but I don't yet know how. Should be easy enough to find:
"solving poisson with fft". Numerical Recipes has nice code for 3D FFT
which calculates the solution in-place saving memory.

Laplace: u(xx) + u(yy) = 0
u(xx) = 2nd derivative of u over variable x

Here u is potential (hf height). x and y are hf coordinates.
Resulting difference formula in free areas (x,y) + 1 pixel boundary:

u(x+1,y) + u(x,y+1) + u(x-1,y) + u(x,y-1) = 4*u(x,y)

So basically the procedure is: Take surrounding 4 pixels and put
the average in the middle. Repeat for all free pixels (x,y). If
there are n free pixels the resulting linear system is n*5. I solve
this with Gauss-Seidel iteration.

More on this method in Advanced Engineering Mathematics by Kreyszig
in section Numerical methods for differential equations.


I sent this uncleaned code to the Terragen guy and he made it a new filter.

------------------------------------------------------------------
LevelConnector uses these pseudo functions to communicate with the
rest of the app.

  SetHeight(x, y, hv);      
  hv=GetHeight(x, y);
  Sel=GetSelValue(x, y); // is pixel selected
  PixV=HVToFloat(hv);    // convert from internal type to float
  hv=FloatToHV(PixV);    // convert to internal type


//def for the compare func used by bsearch
typedef int (*fptr)(const void*, const void*);

int compare(const int *a,const int *b)
{
  return(*a - *b);
}


// The main calculations. Processes data in u[].
// Solves this Laplace's 2nd order differential
// equation using Gauss-Seidel iteration.
//
//   d2u   d2u
//   --- + --- = 0 + (force, not used)  
//   dx2   dy2
//
// Can be solved by FFT also but this iterative method lets user control
// the accuracy of the solution. If all pixels are selected then this works
// like smooth with variable radius. Basically it just averages 4 adjacent
// pixels into the middle pixel :) Note however that one iteration pass uses
// uses 2 values per pixel already computed in that pass so it's a kind of
// cumulative smooth.

void SolveEquations(int **s, float *h, float *u, int Nodes, int maxiter)
{
  int i,c,dir=1,Node;
  float sum;

  for(i=0;i<maxiter;i++)
    {for(Node=(Nodes-1)*(1-dir)/2;dir*Node<=(Nodes-1)*(1+dir)/2;Node=Node+dir)
        { sum=h[Node];
          for(c=1;c<=s[Node][0];c++)
            sum=sum+u[s[Node][c]];
          u[Node]=0.25*sum;
        }
      dir=-dir;  // toggle direction
    }
}


// Prepares data for SolveEquations

void LevelConnector(int width,int height, int maxiter)
{
  int xo[4]={1,-1,0,0},yo[4]={0,0,1,-1};
  int c,Nodes=0,*NodeP,Node,PixN;
  int x,y,xt,yt,i,j,*Pos,**s;
  float *h,*u,Sel,PixV,k;

  // Count selected pixels
  for(y=0;y<height;y++)
    {for(x=0;x<width;x++)
       {if(GetSelValue(x, y) == SELECTED)
          Nodes++;
       }
    } 

  u=(float *)malloc(Nodes*sizeof(float)); // This is the actual height data
  h=(float *)malloc(Nodes*sizeof(float)); // aux data for equations
  Pos=(int *)malloc(Nodes*sizeof(int));   // Stores pixel positions of nodes
  s=(int **)malloc(Nodes*sizeof(int *));  // aux data for equations


  // clear arrays
  for(Node=0;Node<Nodes;Node++)
  { 
    s[Node]=(int *)malloc(5*sizeof(int));
    if (s[Node] == NULL) {perror("memory error");exit(1);}
    for(j=0;j<5;j++)
      s[Node][j]=0;
    u[Node]=0;
    h[Node]=0;
    Pos[Node]=0;
  }


  // Fill position table
  Node=0;PixN=0;
  for(y=0;y<height;y++)
    {for(x=0;x<width;x++)
       {Sel=GetSelValue(x, y);
        if(Sel == SELECTED)
          {Pos[Node]=PixN;
           Node++;
          }
        PixN++;
       }
    }


  // Make equations
  Node=0;PixN=0;
  for(y=0;y<height;y++)
    {for(x=0;x<width;x++)
       {if(GetSelValue(x, y) == SELECTED)
          {k=0;c=0;
	   for(i=0;i<4;i++)
             {yt=y+yo[i];
              xt=x+xo[i];
              if (yt == -1)      yt=height-1;
	      if (yt == height) yt=0;
	      if (xt == -1)      xt=width-1;
	      if (xt == width)   xt=0;
              hv=GetHeight(xt, yt);
              PixV=HVToFloat(hv);
              if(GetSelValue(xt, yt) != SELECTED)
                k=k+PixV;
              else
                {c++;
                 PixN=yt*width+xt;
	         NodeP=(int *)bsearch(&PixN,Pos,Nodes,sizeof(int),(fptr)compare);
                 if(NodeP == NULL)
                   {perror("error in bserch");
                    exit(1);
                   }
                 s[Node][c]=(int)(NodeP-Pos);
                }
	     }
           hv=GetHeight(x, y);
           u[Node]=HVToFloat(hv);
	   h[Node]=k;
	   // h[Node]=k-force;  past experiment
	   s[Node][0]=c;
	   Node++;
	  }
       }
    }

  SolveEquations(s,h,u,Nodes,maxiter);
  free(h);
  
  // Write data in u[] back to hf
  for(Node=0;Node<Nodes;Node++)
    { 
      free(s[Node]);
      hv=FloatToHV(u[Node]);
      x=Pos[Node]%width;
      y=Pos[Node]/width;
      SetHeight(x, y, hv);
    }
  
  free(s);
  free(Pos);
  free(u);
}

K.K.


Post a reply to this message

From: Chris Huff
Subject: Re: Anybody know this site?
Date: 12 Aug 2000 16:33:38
Message: <chrishuff-440A3B.15344512082000@news.povray.org>
In article <3995801A.AC206C81@kivisalo.net>, Kari Kivisalo 
<kar### [at] kivisalonet> wrote:

> Here is the theory on 2d electrical potential and how to obtain 
> numerical approximation using difference equations and iterations. 
> This can be solved with FFT also but I don't yet know how. Should be 
> easy enough to find: "solving poisson with fft". Numerical Recipes 
> has nice code for 3D FFT which calculates the solution in-place 
> saving memory.

Thanks...it looks like it will take a while to analyze this and convert 
it to 3d, though. I guess it would help if I had some calculus...and 
don't expect a FFT solving method from me. :-)

-- 
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/


Post a reply to this message

From: 25ct
Subject: Re: Anybody know this site?
Date: 12 Aug 2000 17:23:51
Message: <3995c067@news.povray.org>
"Kari Kivisalo" <kar### [at] kivisalonet> wrote in message
news:3995801A.AC206C81@kivisalo.net...
> Chris Huff wrote:
> >
> > Could you give more details on how you calculate
> > it? I didn't see an in-depth explanation on the site.
>
> Here is the theory on 2d electrical potential and how to obtain numerical
> approximation using difference equations and iterations. This can be
solved
> with FFT also but I don't yet know how. Should be easy enough to find:
> "solving poisson with fft". Numerical Recipes has nice code for 3D FFT
> which calculates the solution in-place saving memory.
>
> Laplace: u(xx) + u(yy) = 0
> u(xx) = 2nd derivative of u over variable x
>
> Here u is potential (hf height). x and y are hf coordinates.
> Resulting difference formula in free areas (x,y) + 1 pixel boundary:
>
> u(x+1,y) + u(x,y+1) + u(x-1,y) + u(x,y-1) = 4*u(x,y)
>
> So basically the procedure is: Take surrounding 4 pixels and put
> the average in the middle. Repeat for all free pixels (x,y). If
> there are n free pixels the resulting linear system is n*5. I solve
> this with Gauss-Seidel iteration.
>
> More on this method in Advanced Engineering Mathematics by Kreyszig
> in section Numerical methods for differential equations.
>
>
> I sent this uncleaned code to the Terragen guy and he made it a new
filter.
>
> ------------------------------------------------------------------
> LevelConnector uses these pseudo functions to communicate with the
> rest of the app.
>
>   SetHeight(x, y, hv);
>   hv=GetHeight(x, y);
>   Sel=GetSelValue(x, y); // is pixel selected
>   PixV=HVToFloat(hv);    // convert from internal type to float
>   hv=FloatToHV(PixV);    // convert to internal type
>
>
> file://def for the compare func used by bsearch
> typedef int (*fptr)(const void*, const void*);
>
> int compare(const int *a,const int *b)
> {
>   return(*a - *b);
> }
>
>
> // The main calculations. Processes data in u[].
> // Solves this Laplace's 2nd order differential
> // equation using Gauss-Seidel iteration.
> //
> //   d2u   d2u
> //   --- + --- = 0 + (force, not used)
> //   dx2   dy2
> //
> // Can be solved by FFT also but this iterative method lets user control
> // the accuracy of the solution. If all pixels are selected then this
works
> // like smooth with variable radius. Basically it just averages 4 adjacent
> // pixels into the middle pixel :) Note however that one iteration pass
uses
> // uses 2 values per pixel already computed in that pass so it's a kind of
> // cumulative smooth.
>
> void SolveEquations(int **s, float *h, float *u, int Nodes, int maxiter)
> {
>   int i,c,dir=1,Node;
>   float sum;
>
>   for(i=0;i<maxiter;i++)
>
{for(Node=(Nodes-1)*(1-dir)/2;dir*Node<=(Nodes-1)*(1+dir)/2;Node=Node+dir)
>         { sum=h[Node];
>           for(c=1;c<=s[Node][0];c++)
>             sum=sum+u[s[Node][c]];
>           u[Node]=0.25*sum;
>         }
>       dir=-dir;  // toggle direction
>     }
> }
>
>
> // Prepares data for SolveEquations
>
> void LevelConnector(int width,int height, int maxiter)
> {
>   int xo[4]={1,-1,0,0},yo[4]={0,0,1,-1};
>   int c,Nodes=0,*NodeP,Node,PixN;
>   int x,y,xt,yt,i,j,*Pos,**s;
>   float *h,*u,Sel,PixV,k;
>
>   // Count selected pixels
>   for(y=0;y<height;y++)
>     {for(x=0;x<width;x++)
>        {if(GetSelValue(x, y) == SELECTED)
>           Nodes++;
>        }
>     }
>
>   u=(float *)malloc(Nodes*sizeof(float)); // This is the actual height
data
>   h=(float *)malloc(Nodes*sizeof(float)); // aux data for equations
>   Pos=(int *)malloc(Nodes*sizeof(int));   // Stores pixel positions of
nodes
>   s=(int **)malloc(Nodes*sizeof(int *));  // aux data for equations
>
>
>   // clear arrays
>   for(Node=0;Node<Nodes;Node++)
>

>     s[Node]=(int *)malloc(5*sizeof(int));
>     if (s[Node] == NULL) {perror("memory error");exit(1);}
>     for(j=0;j<5;j++)
>       s[Node][j]=0;
>     u[Node]=0;
>     h[Node]=0;
>     Pos[Node]=0;
>   }
>
>
>   // Fill position table
>   Node=0;PixN=0;
>   for(y=0;y<height;y++)
>     {for(x=0;x<width;x++)
>        {Sel=GetSelValue(x, y);
>         if(Sel == SELECTED)
>           {Pos[Node]=PixN;
>            Node++;
>           }
>         PixN++;
>        }
>     }
>
>
>   // Make equations
>   Node=0;PixN=0;
>   for(y=0;y<height;y++)
>     {for(x=0;x<width;x++)
>        {if(GetSelValue(x, y) == SELECTED)
>           {k=0;c=0;
>    for(i=0;i<4;i++)
>              {yt=y+yo[i];
>               xt=x+xo[i];
>               if (yt == -1)      yt=height-1;
>       if (yt == height) yt=0;
>       if (xt == -1)      xt=width-1;
>       if (xt == width)   xt=0;
>               hv=GetHeight(xt, yt);
>               PixV=HVToFloat(hv);
>               if(GetSelValue(xt, yt) != SELECTED)
>                 k=k+PixV;
>               else
>                 {c++;
>                  PixN=yt*width+xt;
>          NodeP=(int *)bsearch(&PixN,Pos,Nodes,sizeof(int),(fptr)compare);
>                  if(NodeP == NULL)
>                    {perror("error in bserch");
>                     exit(1);
>                    }
>                  s[Node][c]=(int)(NodeP-Pos);
>                 }
>      }
>            hv=GetHeight(x, y);
>            u[Node]=HVToFloat(hv);
>    h[Node]=k;
>    // h[Node]=k-force;  past experiment
>    s[Node][0]=c;
>    Node++;
>   }
>        }
>     }
>
>   SolveEquations(s,h,u,Nodes,maxiter);
>   free(h);
>
>   // Write data in u[] back to hf
>   for(Node=0;Node<Nodes;Node++)
>

>       free(s[Node]);
>       hv=FloatToHV(u[Node]);
>       x=Pos[Node]%width;
>       y=Pos[Node]/width;
>       SetHeight(x, y, hv);
>     }
>
>   free(s);
>   free(Pos);
>   free(u);
> }
>
> K.K.


   Aaaaaaaargh!!!  You've frightened the s**t out of me now
  Kari!!  Whats a man to do?? (Need new specs after that! Me 'eads gone all
dizzy!! ;o)

                                ~Steve~

    PS, how do I save an image as .jpg, *in POV-Ray*, to 'send' to you very
'NICE' people to perooooose over? Simple question, I know, but I'M sure that
you can handle it, Kari............thanx.


Post a reply to this message

From: Chris Huff
Subject: Re: Anybody know this site?
Date: 12 Aug 2000 17:45:09
Message: <chrishuff-CC5169.16461612082000@news.povray.org>
In article <3995c067@news.povray.org>, "25ct" <25c### [at] lineonenet> wrote:

>     PS, how do I save an image as .jpg, *in POV-Ray*, to 'send' to you 
> very 'NICE' people to perooooose over? Simple question, I know, but 
> I'M sure that you can handle it, Kari............thanx.

You don't. You have to use an external program to convert an image 
generated by POV(in PNG or TGA format, for example) to JPEG. The next 
version may include JPEG *input*, but JPEG, as a "lossy" format, won't 
be available for output.

-- 
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/


Post a reply to this message

From: 25ct
Subject: Re: Anybody know this site?
Date: 12 Aug 2000 18:23:46
Message: <3995ce72@news.povray.org>
So what do I *do* If I haven't got PNG? or TGA?
  I've got Photo deluxe 2.0,(Hahaha!!) and PS 5 (LE, nice!). Deluxe can
convert an image to .jpeg, but it won't do it, with Pov.
   I am at a loss, so far!

                   ~Steve~     (What? Where? When? ;o)




"Chris Huff" <chr### [at] maccom> wrote in message
news:chrishuff-CC5169.16461612082000@news.povray.org...
> In article <3995c067@news.povray.org>, "25ct" <25c### [at] lineonenet> wrote:
>
> >     PS, how do I save an image as .jpg, *in POV-Ray*, to 'send' to you
> > very 'NICE' people to perooooose over? Simple question, I know, but
> > I'M sure that you can handle it, Kari............thanx.
>
> You don't. You have to use an external program to convert an image
> generated by POV(in PNG or TGA format, for example) to JPEG. The next
> version may include JPEG *input*, but JPEG, as a "lossy" format, won't
> be available for output.
>
> --
> Christopher James Huff - Personal e-mail: chr### [at] maccom
> TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
> Personal Web page: http://homepage.mac.com/chrishuff/
> TAG Web page: http://tag.povray.org/


Post a reply to this message

From: Chris Huff
Subject: Re: Anybody know this site?
Date: 12 Aug 2000 18:42:45
Message: <chrishuff-73B1CD.17435312082000@news.povray.org>
In article <3995ce72@news.povray.org>, "25ct" <25c### [at] lineonenet> wrote:

>     So what do I *do* If I haven't got PNG? or TGA?
>   I've got Photo deluxe 2.0,(Hahaha!!) and PS 5 (LE, nice!). Deluxe can
> convert an image to .jpeg, but it won't do it, with Pov.
>    I am at a loss, so far!

What do you mean?
Are you trying to convert a .pov file? That won't work, you have to 
render it with POV and convert the resulting image. POV-Ray can output 
to many file formats, including TGA and PNG. The default settings place 
the rendered image in the same folder the .pov file is in.

-- 
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/


Post a reply to this message

From: Bob Hughes
Subject: Re: Anybody know this site?
Date: 13 Aug 2000 03:48:05
Message: <399652b5@news.povray.org>
"Chris Huff" <chr### [at] maccom> wrote in message
news:chrishuff-73B1CD.17435312082000@news.povray.org...
| In article <3995ce72@news.povray.org>, "25ct" <25c### [at] lineonenet> wrote:
|
| >     So what do I *do* If I haven't got PNG? or TGA?
| >   I've got Photo deluxe 2.0,(Hahaha!!) and PS 5 (LE, nice!). Deluxe can
| > convert an image to .jpeg, but it won't do it, with Pov.
| >    I am at a loss, so far!
|
| What do you mean?
| Are you trying to convert a .pov file? That won't work, you have to
| render it with POV and convert the resulting image. POV-Ray can output
| to many file formats, including TGA and PNG. The default settings place
| the rendered image in the same folder the .pov file is in.

My guess is that (s)he is saying that nothing there is capable of opening a
Targa or Portable Network Graphics image.  But only because I'm not sure
about what either of those programs can open.  Somehow I'd bet Photoshop
could do it, just a hunch.

Bob


Post a reply to this message

From: Kari Kivisalo
Subject: Re: Anybody know this site?
Date: 13 Aug 2000 03:59:49
Message: <3996558A.CDAA55FF@kivisalo.net>
Chris Huff wrote:
>
> > Here is the theory on 2d electrical potential
> > u(xx) + u(yy) = 0
> > u(x+1,y) + u(x,y+1) + u(x-1,y) + u(x,y-1) = 4*u(x,y)
>
> Thanks...it looks like it will take a while to analyze this and convert
> it to 3d, though.

I think the equations  would just be

u(xx) + u(yy) + u(zz) = 0 and

u(x+1,y,z) + u(x,y+1,z) + u(x-1,y,z) + u(x,y-1,z) + u(x,y,z+1) + u(x,y,z-1) =
6*u(x,y,z)

I could convert my code quite easy to 3D for testing purposes but it would
require lots of RAM to run. Then I would write a macro that outputs an object/volume
as voxel image slice by slice as animation. What's the format of the pov
voxel image type (for input to pov)?

This setup would be enough to determine how useful Volume Connector :) vould be.


K.K.


Post a reply to this message

From: ingo
Subject: Re: Anybody know this site?
Date: 13 Aug 2000 04:06:15
Message: <8F8F6FFC6seed7@204.213.191.228>
Kari Kivisalo wrote:

>What's the format of the pov
>voxel image type (for input to pov)?

The density_file.

from the doc: "The df3 format consists of a 6 byte header of three 16-bit 
integers with high order byte first. These three values give the x,y,z 
size of the data in pixels (or more appropriately called voxels). This is 
followed by x*y*z unsigned integer bytes of data. The data in the range of 
0 to 255 is scaled into a float value in the range 0.0 to 1.0. It remains 
at 0.0 for all areas beyond the unit cube. The pattern occupies the unit 
cube regardless of the dimensions in voxels."

Ingo

-- 
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/


Post a reply to this message

<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>

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