# How to make each irregular polyhedron randomly generated in makeCloud different?

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:

Jie

########################
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()
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 #s stores center
b.state.ori = Quaternion((random.random(),random.random(),random.random()),random.random()) #s
O.bodies.append(b)

v=qt.View()
O.saveTmp()

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2020-05-21
Last query:
2020-05-21
2020-05-20 Jan Stránský (honzik) said on 2020-05-20: #1

Hello,

> b=polyhedra_utils.polyhedra(...,seed=5,...)

use different seed, e.g.
###
for i,s in enumerate(sp):
...
b=polyhedra_utils.polyhedra(...,seed=i+1,...)
###

or do not set seed at all.

cheers
Jan

 weijie (amandajoe) said on 2020-05-21: #2

Thanks Jan Stránský, that solved my question.