← Back to team overview

yade-users team mailing list archive

[Question #690845]: How to make each irregular polyhedron randomly generated in makeCloud different?

 

New question #690845 on Yade:
https://answers.launchpad.net/yade/+question/690845

Dear all,

I used the polyhedra_utils.polyhedra function to create irregular polyhedrons. How to make each irregular polyhedron different in the makeCloud space? 

Below is my MWS:

Thanks in advance.
Jie

########################
from yade import polyhedra_utils,pack,plot,utils,qt
import random
import numpy as np

#-------------------------------------------
#Material
n = PolyhedraMat(young=7.2e7,poisson=.2,density=2.5e3) 

#-------------------------------------------
#Dimensions

meanSize = 0.05
wallThickness = 0.5*meanSize
distanceToCentre = 0.01
lengthOfBase = 0.250
heightOfBase = 0.600

#-------------------------------------------
#Make Cloud

sp=pack.SpherePack() 
mn,mx=Vector3(-0.5*(lengthOfBase-wallThickness),0.5*meanSize,-0.5*(lengthOfBase-wallThickness)),Vector3(0.5*(lengthOfBase-wallThickness),0.5*heightOfBase,0.5*(lengthOfBase-wallThickness))
R=sqrt(3.0)*distanceToCentre 
sp.makeCloud(mn,mx,R,0,-1,False)

for s in sp:
    b=Body()
    b.mask=1
    color=Vector3(random.random(),random.random(),random.random())
    b=polyhedra_utils.polyhedra(material=n,size=(2*distanceToCentre,distanceToCentre,distanceToCentre),seed=5,color=color)
    b.state.pos = s[0] #s[0] stores center
    b.state.ori = Quaternion((random.random(),random.random(),random.random()),random.random()) #s[2]
    O.bodies.append(b)
  
from yade import qt
v=qt.View()
O.saveTmp()

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