yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #22972
Re: [Question #690438]: How to generate a regular dodecahedron in polyhedra_utils module?
Question #690438 on Yade changed:
https://answers.launchpad.net/yade/+question/690438
Status: Open => Answered
Vasileios Angelidakis proposed the following answer:
Hi Jie,
You define the vertices in a tuple of tuples ((x,y,z), ...). Tuples and
lists in Python do not allow you to multiply each element with a scalar.
On the other hand, Vector3 (from the Eigen library) and array (from
numpy) allow you to do this. So, I created your vertices as an array of
Vector3 elements. Then, the scale factor you want, is
SF=newEdge/oldEdge.
Some advice:
- Use color=[0,0,1] to get a blue particle. Values over 1 inside the color will mess up shading :)
- I activated the grid for you, so you can inspect the particle size yourself (with v.ortho=True). You can modify the density of the grid with the plus-minus keys.
Best Regards,
Vasileios
from yade import polyhedra_utils,pack,plot,utils,export,qt,ymport
import numpy as np
import math
import random
n = PolyhedraMat(young=7.2e7,poisson=.2,density=2.5e3)
O.materials.append(n)
a=(1+math.sqrt(5))/2
d=1
v1=(d,d,d),(d,d,-d),(d,-d,d),(d,-d,-d),(-d,d,d),(-d,d,-d),(-d,-d,d),(-d,-d,-d)
v2=(0,a,1/a),(0,a,-1/a),(0,-a,1/a),(0,-a,-1/a)
v3=(1/a,0,a),(1/a,0,-a),(-1/a,0,a),(-1/a,0,-a)
v4=(a,1/a,0),(a,-1/a,0),(-a,1/a,0),(-a,-1/a,0)
v=((d,d,d),(d,d,-d),(d,-d,d),(d,-d,-d),(-d,d,d),(-d,d,-d),(-d,-d,d),(-d,-d,-d),(0,a,1/a),(0,a,-1/a),(0,-a,1/a),(0,-a,-1/a),(1/a,0,a),(1/a,0,-a),(-1/a,0,a),(-1/a,0,-a),(a,1/a,0),(a,-1/a,0),(-a,1/a,0),(-a,-1/a,0))
#print(v)
vertices=[]
for ver in v:
vertices.append(Vector3(ver))
vertices=np.array(vertices)
oldEdge=sqrt(5)-1
newEdge=9
SF=newEdge/oldEdge
vertices=vertices*SF
b = polyhedra_utils.polyhedra(material=n,v=vertices,fixed=True,color=(0,0,1))
O.bodies.append(b)
from yade import qt
v=qt.View()
v.sceneRadius=30.0
v.grid=(True, True, True)
v.ortho=True
--
You received this question notification because your team yade-users is
an answer contact for Yade.