POV-Ray : Newsgroups : povray.general : Stacking Balls Server Time
13 Aug 2024 15:31:05 EDT (-0400)
  Stacking Balls (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: Chris Maryan
Subject: Stacking Balls
Date: 22 Aug 1998 02:48:34
Message: <35DE59F3.19A5CF68@geocities.com>
I've noticed a number of cool looking images rendered in POVRay that
involve balls/marbles/whatever stacket to look like a random pile (most
notably the image that's on the POVRay 3.02 splash screen). Each of
these images looks like the objects do not intersect but just touch. How
is this usually done? Should I do the math (seems complicated) or is the
only way to just guess and test-render? Maybe someone has a script?
Maybe I am missing the obvious and should just read the docs again?

Any help would be appreciated.

-- 
Chris Maryan
mailto:cma### [at] geocitiescom
***
My ideas are free,
Work is at least minimum wage.
***
Email me if you are interested in donating
to the Chris Maryan needs money fund.


Post a reply to this message

From: K  Tyler
Subject: Re: Stacking Balls
Date: 22 Aug 1998 03:31:40
Message: <35DE5764.4CCFA44A@pacbell.net>
Chris Maryan wrote:

> I've noticed a number of cool looking images rendered in POVRay that
> involve balls/marbles/whatever stacket to look like a random pile (most
> notably the image that's on the POVRay 3.02 splash screen). Each of
> these images looks like the objects do not intersect but just touch. How
> is this usually done? Should I do the math (seems complicated) or is the
> only way to just guess and test-render? Maybe someone has a script?
> Maybe I am missing the obvious and should just read the docs again?
>
> Any help would be appreciated.
> Chris Maryan
> mailto:cma### [at] geocitiescom
> My ideas are free,
> Work is at least minimum wage.



> Email me if you are interested in donating
> to the Chris Maryan needs money fund.

  Please Add me to this list.


---------
  Take a look at the while loop function described in the docs.
It's certainly not the only method but can save a lot of typing
and rendering time. There are also modelers that have a copy
and translate function. One that has this function is PovCad.
You can choose say a sphere for example and then choose the
copy and translate function. A window will pop up asking the
distance to translate, which direction, and the number of copies
desired. It's a pretty handy tool.

Here is an example of a while loop.

camera{location<0,0,-20>look_at 0}
light_source{<0,0,-100>rgb 1}

#declare Count = 0
#while  ( Count < 10 )
sphere{<0,0,0>,1 pigment{rgb 1} translate<-9+Count*2, 0, 0>}
#declare Count = Count+1
#end

This will place ten spheres 5 left and 5 right centered on the screen.
Each touching but not over lapping each other. This also a great
function to accurately crate and rotate a large number of objects.
It certainly bears playing around with for a while to see what it
can do for you.

Happy rendering !

K.Tyler


Post a reply to this message

From: Doug Partridge
Subject: Re: Stacking Balls
Date: 24 Aug 1998 00:42:19
Message: <35E0E118.168F@lawson.appcomp.utas.edu.au>
if you create two spheres

sphere
	{
	<0,0,0>, 1
	}

sphere
	{
	<0,0,2>, 1
	rotate whatever
	}

then whatever the vector whatever is, the two spheres will always be
touching exactly. Obvoiusly it gets a bit harder when you try to put
more spheres.

Obviously this is just a partial solution and I don't really know what
I'm talking about. Oh well
--


Doug Partridge
~
~


Post a reply to this message

From: Friedemann Schmidt
Subject: Re: Stacking Balls
Date: 24 Aug 1998 07:57:45
Message: <35e1472b.1055533@news.povray.org>
Hi,

I think it's a big big problem with more spheres than 2. I wanted to
fill a transparent cylinder with lot of spheres randomly in POV-Ray -
but I gave up... ;-)

I think, one have to simulate each sphere falling from the sky on top
of the other spheres, which have to do a lot with physics. So it
probably can't be done with the script language of POV-Ray.

Bye,
Friedemann


Friedemann Schmidt
Fri### [at] Stonescom
Raytracing-Gallery: http://www.rz.fhtw-berlin.de/~s0049669/


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Stacking Balls
Date: 24 Aug 1998 11:56:22
Message: <35E17EDC.FCDF8CCD@ragingbull.com>
With the array available, it may be possible.... The key is that you
have to store the sphere values and (radius and location) and check your
new sphere against those.  It would be time consuming... Otherwise, I
guess you could would with the distance formula and make each sphere
radius half the distance.  My suggestion would be to do it in a modeller
or by some systemating method that looks random.

Steve


Friedemann Schmidt wrote:
> 
> Hi,
> 
> I think it's a big big problem with more spheres than 2. I wanted to
> fill a transparent cylinder with lot of spheres randomly in POV-Ray -
> but I gave up... ;-)
> 
> I think, one have to simulate each sphere falling from the sky on top
> of the other spheres, which have to do a lot with physics. So it
> probably can't be done with the script language of POV-Ray.
> 
> Bye,
> Friedemann
> 
> Friedemann Schmidt
> Fri### [at] Stonescom
> Raytracing-Gallery: http://www.rz.fhtw-berlin.de/~s0049669/


Post a reply to this message

From: Remco de Korte
Subject: Re: Stacking Balls
Date: 24 Aug 1998 12:08:36
Message: <35E1558E.C0918AC9@xs4all.nl>
Friedemann Schmidt wrote:
> 
> Hi,
> 
> I think it's a big big problem with more spheres than 2. I wanted to
> fill a transparent cylinder with lot of spheres randomly in POV-Ray -
> but I gave up... ;-)
> 
> I think, one have to simulate each sphere falling from the sky on top
> of the other spheres, which have to do a lot with physics. So it
> probably can't be done with the script language of POV-Ray.
> 
> Bye,
> Friedemann
> 
> Friedemann Schmidt
> Fri### [at] Stonescom
> Raytracing-Gallery: http://www.rz.fhtw-berlin.de/~s0049669/

If you have two spheres, and add a third touching the other two, you

with balls, simply by translating and rotating. 
If you want to stack the balls, add a fourth to the first tree, just
touching. Again, this ball is merely translated and rotated. It
shouldn't be that hard to figure out. Obviously some bright minds (like
K. Tyler) have already figured it out, even with spheres of different
sizes.

Regards,

Remco de Korte
http://www.xs4all.nl/~remcodek/


Post a reply to this message

From: K  Tyler
Subject: Re: Stacking Balls
Date: 24 Aug 1998 13:32:30
Message: <35E1873B.C085A853@pacbell.net>
Friedemann Schmidt wrote:

> Hi,
>
> I think it's a big big problem with more spheres than 2. I wanted to
> fill a transparent cylinder with lot of spheres randomly in POV-Ray -
> but I gave up... ;-)
>
> I think, one have to simulate each sphere falling from the sky on top
> of the other spheres, which have to do a lot with physics. So it
> probably can't be done with the script language of POV-Ray.
>
> Bye,
> Friedemann
>
> Friedemann Schmidt
> Fri### [at] Stonescom
> Raytracing-Gallery: http://www.rz.fhtw-berlin.de/~s0049669/

  I once asked if anybody had developed a routine for object collision
avoidance which I believe is what you will need to fill a cylinder or
any other shape without them overlapping. Dan Connely replied that
he had seen one recently but I can't remember where the posted reply
is located at. Dan if your out there could you fill in the blanks.

K.Tyler


Post a reply to this message

From: Friedemann Schmidt
Subject: Re: Stacking Balls
Date: 24 Aug 1998 15:46:21
Message: <35e1b4f5.29165353@news.povray.org>
Hi,

>  I once asked if anybody had developed a routine for object collision
>avoidance which I believe is what you will need to fill a cylinder or
>any other shape without them overlapping. Dan Connely replied that
>he had seen one recently but I can't remember where the posted reply
>is located at. Dan if your out there could you fill in the blanks.

I just wrote a little macro which fills a cylinder with spheres
randomly without overlapping. The problems are, that it takes a long
time to render for many spheres in a small cylinder and that the
spheres doesn't contact each other. So it can only be used to fill a
shape in space without gravitation ;-)

The parameter variables are:
  SeedNr: value for initializing the random stream
  CylRadius: Radius of the cylinder
  CylHeight: Height of the cylinder
  Count: The number of spheres to create
  MinSize: Minimum size of a sphere
  MaxSize: Maximum size of a sphere
  MaxLoops: After this number of loops the macro will be interrupted
if no new position for a sphere can be found.

The cylinder is based on the X-Z-floor.

Example:  FillCylinder(1, 1, 2, 500, 0.1, 0.1, 100) 
(It took 50 seconds on my computer by parsing...)

A macro for filling a sphere or a box could be written easily by the
same way.

By the way, the macro can also be used by

union {
  FillCylinder(1, 1, 2, 500, 0.1, 0.1, 100)
  rotate...
  translate ...
}

#macro FillCylinder(SeedNr, CylRadius, CylHeight, Count, MinSize,
MaxSize, MaxLoops)
  #local Seed = seed(SeedNr);
  #local Pos = array[Count]
  #local Size = array[Count]

  #local i = 0;
  #local Loops = 0;
  #while (i < Count & Loops < MaxLoops)
    #local Size[i] = rand(Seed)*(MaxSize-MinSize)+MinSize;
    
    #local Break = false;
    #while (Break = false)
      #local X = rand(Seed)*(CylRadius-Size[i])*2-(CylRadius-Size[i]);
      #local Z = rand(Seed)*(CylRadius-Size[i])*2-(CylRadius-Size[i]);
      #if (vlength(<X, 0, Z>) <= CylRadius-Size[i])
        #local Break = true;
      #end
    #end
    #local Y = rand(Seed)*(CylHeight-2*Size[i])+Size[i];
    #local Pos[i] = <X, Y, Z>;
    
    #local ShowIt = true;
    #local j = 0;
    #while (j < i & ShowIt = true)
      #if (vlength(Pos[j]-Pos[i])-Size[j]-Size[i] < 0)
        #local ShowIt = false;
      #end
      #local j = j + 1;
    #end
      
    #if (ShowIt = true)    
      #debug concat("Sphere ", str(i+1, 0, 0), "\n")
      sphere {
        Pos[i], Size[i]
        pigment { color rgb <1, 0, 0> }
      }
      #local i = i + 1;
      #local Loops = 0;
    #else
      #local Loops = Loops + 1;
    #end
  #end
  #if (Loops > 0)
    #debug concat(">>> Break after ", str(Loops, 0, 0), " loops!\n")
  #end
#end

Bye,
Friedemann




Friedemann Schmidt
Fri### [at] Stonescom
Raytracing-Gallery: http://www.rz.fhtw-berlin.de/~s0049669/


Post a reply to this message

From: Friedemann Schmidt
Subject: Re: Stacking Balls
Date: 24 Aug 1998 15:46:30
Message: <35e1b50f.29191907@news.povray.org>
Hi,

the problem is, that this won't fill a shape randomly. It looks very
regular, doesn't it?

Bye,
Friedemann


Friedemann Schmidt
Fri### [at] Stonescom
Raytracing-Gallery: http://www.rz.fhtw-berlin.de/~s0049669/


Post a reply to this message

From: Remco de Korte
Subject: Re: Stacking Balls
Date: 24 Aug 1998 18:33:47
Message: <35E1DD33.271759D5@xs4all.nl>
Friedemann Schmidt wrote:
> 
> Hi,
> 
> the problem is, that this won't fill a shape randomly. It looks very
> regular, doesn't it?
> 
> Bye,
> Friedemann
> 
> Friedemann Schmidt
> Fri### [at] Stonescom
> Raytracing-Gallery: http://www.rz.fhtw-berlin.de/~s0049669/

Yep, like if you filled a tube with identical sized marbles they would
fall neatly in a pattern if it weren't for the tube. I never tried
stacking marbles on an open surface, I think it would be very hard, and
then I guess you could also forget about the randomness. I might be
mistaken but I think that randomness in a stack of marbles (of the same
size) is not very realistic.

Regards,

Remco de Korte
'the iceman cometh' as K. Tyler once said ;-) at
http:www.xs4all.nl/~remcodek/


Post a reply to this message

Goto Latest 10 Messages Next 5 Messages >>>

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