Any ideas on how to make a lot of rice to fill a bowl? I made an
individual grain of rice, but it seems silly to have to translate it a
thousand times by hand.
Thanks,
John Millstead
jmi### [at] mckinleycapitalcom
From: Nieminen Mika
Subject: Re: A bowl of rice
Date: 21 May 1998 14:47:04
Message: <6k1sr8$k9k$1@oz.aussie.org>
John T. Millstead <jmi### [at] mckinleycapitalcom> wrote:
: Any ideas on how to make a lot of rice to fill a bowl? I made an
: individual grain of rice, but it seems silly to have to translate it a
: thousand times by hand.
If you know which function defines the inner surface of the bowl (for
example if it's a spherical surface it's really easy) you can use a
#while loop and position thousands of rice grains with the rand function
inside the bowl with the function that defines it (I don't know if you
understood... my english is not very good :) )
An example says more than 1000 words (I think :) )
#declare MinX=-10
#declare MaxX=10
#declare MinY=-10
#declare MaxY=0
#declare MinZ=-10
#declare MaxZ=10 // All the grains will be inside these coordinates
#declare Amount=1000 // The amount of grains
#declare R=seed(0)
#while(Amount>0)
#declare PosX=MaxX+1
#declare PosY=0
#declare PosZ=0 // A hack to make the script work
#while(PosX>MaxX |
PosX*PosX+PosY*PosY+PosZ*PosZ > 10*10) // this is the function that
// defines a sphere
#declare PosX=MinX+rand(R)*(MaxX-MinX)
#declare PosY=MinY+rand(R)*(MaxY-MinY)
#declare PosZ=MinZ+rand(R)*(MaxZ-MinZ)
#end
object { Grain translate <PosX,PosY,PosZ> }
#declare Amount=Amount-1
#end
This isn't a very efficient algorithm, since it calculates a lot of misses,
but it works anyways :)
It's also quite easy to distribute the grains in the border of the function.
--
- Warp. -
Thanks so much. It put me on the right track. It's always nice to
learn something new.
John
> John T. Millstead <jmi### [at] mckinleycapitalcom> wrote:> : Any ideas on how to make a lot of rice to fill a bowl? I made an> : individual grain of rice, but it seems silly to have to translate it> a> : thousand times by hand.> Nieminen Mika wrote: If you know which function defines the inner> surface of the bowl (for> example if it's a spherical surface it's really easy) you can use a> #while loop and position thousands of rice grains with the rand> function> inside the bowl with the function that defines it (I don't know if you>> understood... my english is not very good :) )>
Nieminen Mika <war### [at] assaricctutfi> wrote:
> If you know which function defines the inner surface of the bowl (for> example if it's a spherical surface it's really easy) you can use a> #while loop and position thousands of rice grains with the rand function> inside the bowl with the function that defines it (I don't know if you> understood... my english is not very good :) )> An example says more than 1000 words (I think :) )>
The problem probably isn't *that* simple. I haven't run your code but
I expect the ricegrains to intersect each other... right? Maybe that
dosn't matter since if you boild rice to hard they clutter together
but it might be worth to mention in case anyone want to adapt this
method to something else...
/ Mathias Broxvall.
PS. I'd write a small hack in C that generates the positions of the
rice grains, that way I can create a list of all current ricegrains
and check for intersections when I place a new ricegrain... Though
that would take O(n^2) time instead of linear time...
.DS