POV-Ray : Newsgroups : povray.general : Pile of sticks? : Re: Pile of sticks? Server Time
3 Aug 2024 22:10:26 EDT (-0400)
  Re: Pile of sticks?  
From: JC (Exether)
Date: 1 Oct 2003 03:00:13
Message: <3f7a7b7d$1@news.povray.org>
I have exactly the same problem, I posted an equivalent message on 
09/15/2003 18:08 same forum. I've tried to use approximation algorithms, 
but avoiding coincidence is really a problem. When I manage to avoid 
coincidence, the sticks have big gaps between them and the pile doesn't 
really look like a pile. I ended up trying the MegaPOV mechsim 
functionalities, but they tend to take ages (it's still running at the 
moment I write this message), and I think it's a bit overkill. But maybe 
I just need to find the proper parameters for my purpose as I don't need 
an accurate movement, but only an accurate final state.

Yesterday I wrote a macro wich could be improved further and which 
performs not too bad. It's something like :

#local My_Seed = seed(0);

#declare F_Profil =function (Rayon_Max, hmax, h) { 
min(sin(pi*(1-h/hmax)/2)*(1.4*Rayon_Max), Rayon_Max) }

// ------------------------------------------------
#macro Tas (obj, Mrayon, Nrangee)

#local A=min_extent (obj);
#local B=max_extent (obj);
#local longueur=B.x-A.x;
#local rayon=(B.y-A.y)/2;

#debug concat ("longueur = ", str (longueur, 0, 2), "    rayon = ", str 
(rayon, 0, 2), "\n")

#local compteur=0;

#local j = 0;
#while (j < Nrangee)
   #local xp = -F_Profil (Mrayon, Nrangee, j);
   #while (xp < F_Profil (Mrayon, Nrangee, j))
     object {
       Vobj
       rotate 90*y + <rand(My_Seed), rand(My_Seed), rand(My_Seed)>*10
       translate
       <xp,
       rayon*(1+2*j)*0.3,
       2*sqrt(1 - pow(xp/Mrayon, 2))*(rand(My_Seed)-0.5)*F_Profil 
(Mrayon, Nrangee, j) >
       rotate <0,360*rand(My_Seed),0>
     }
     #local xp = xp + 0.8*rayon*2;
     #local compteur=compteur+1;
   #end
   #local j = j + 1;
#end
#debug concat ("nombre d'objets = ", str (compteur, 0, 2), "\n")
#end

#declare Vobj=object { ... whatever }

union { Tas (Vobj, 5, 35) }
cylinder { <0,-0.1,0>, <0, 0,0>, 5 pigment { rgb <0.8,0.5,0.5> } }


But i'm still interested by a real solution. That's for my IRTC entry, 
so I still a month to figure it out.

JC

-s0da- wrote:
> Anyone got a good algorithm that'll create a pile of sticks?
> much like you'd find in a small fire?
> 
> I have an idea, but can't seem to avoid intersections.  i.e.
> dont' really want sticks that are going THROUGH each
> other.  like to take into account that part of one stick can't
> occupy the same space as another.
> 
> Any help pointing me in the right direction would be greatly
> appreciated.


Post a reply to this message

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