← Back to team overview

yade-users team mailing list archive

Re: [Question #294908]: Remove Spheres Randomicaly from Pack

 

Question #294908 on Yade changed:
https://answers.launchpad.net/yade/+question/294908

Jan Stránský proposed the following answer:
Hi Luis,
I like the approach of Veljko.
Aternativally you can implement something like removeRandom() method, but
it would need some c++ coding (as the core of SpherePack is implemented in
c++)
cheers
Jan


2016-06-06 12:58 GMT+02:00 velimier <question294908@xxxxxxxxxxxxxxxxxxxxx>:

> Question #294908 on Yade changed:
> https://answers.launchpad.net/yade/+question/294908
>
>     Status: Open => Answered
>
> velimier proposed the following answer:
> Hi,
> maybe you can randomly append spheres from packing but excluding certain
> number of spheres.
>
> from yade import pack
> import random
>
> sp = SpherePack()
> sp = pack.regularOrtho(pack.inAlignedBox((0,0,0),(1,1,1)),radius=.05,gap=0)
>
> n=350 #number of spheres to exclude
>
> #randomly append spheres from packing
> for i in range(0, len(sp)-n):
>     b = sp[random.randint(0,len(sp)-1)]
>     O.bodies.append(b)
>     sp.remove(b)
>
> Hope it suits your need,
> Veljko
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.