The polyhedron of specified vertices translates into Potential Blocks and a strange question about Vector3
Hi, everyone,
I generate a polyhedra whose vertices are fixed. But when I translate it to Potential Blocks there is a problem that the number of Potential Block vertices is more than the original polyhedra. I think it may be due to some error that makes the expression of the faces converted from these vertices inaccurate. However, when I do not specify the vertices of the polyhedron and let yade generate randomly, this problem does not arise. I want to know how to solve this problem. Here is my code.
#####################
from yade import polyhedra_utils,pack,plot,utils,export,qt,ymport
import numpy as np
import math
import random
#########################################################################Define physical parameters
powderDensity = 2500
O.materials.append(FrictMat(young=-1,poisson=-1,frictionAngle=radians(0.0),density=powderDensity,label='frictionless'))
young = 1e9
FricDegree1= atan(.6)
m = PolyhedraMat()
m.density = powderDensity
m.young = young
m.poisson = 0.25
m.frictionAngle = FricDegree1
VV = [Vector3(.00, .00, .04),
Vector3(.028, .00, .028),
Vector3(.02, .02, .028),
Vector3(.00, .028, .028),
Vector3(-.028, .00, .028),
Vector3(-.02, .02, .028),
Vector3(-.02, -.02, .028),
Vector3(.00, -.028, .028),
Vector3(.02, -.02, .028),
Vector3(.04, .00, .00),
Vector3(.028, .028, .00),
Vector3(.00, .04, .00),
Vector3(-.04, .00, .00),
Vector3(-.028, .028, .00),
Vector3(-.028, -.028, .00),
Vector3(.00, -.04, .00),
Vector3(.028, -.028, .00),
Vector3(.00, .00, -.04),
Vector3(.028, .00, -.028),
Vector3(.02, .02, -.028),
Vector3(.00, .028, -.028),
Vector3(-.028, .00, -.028),
Vector3(-.02, .02, -.028),
Vector3(-.02, -.02, -.028),
Vector3(.00, -.028, -.028),
Vector3(.02, -.02, -.028)]
#####################################################################
t = polyhedra_utils.polyhedra(m,v=VV) #size=(0.06,0.06,0.06)
# t = polyhedra_utils.polyhedra(m,size=(0.06,0.06,0.06),seed = 3) #no special vertices
O.bodies.append(t)
#######################################################################
def dvalue(vecn1,pp1):
dd1=1*(vecn1[0]*pp1[0]+vecn1[1]*pp1[1]+vecn1[2]*pp1[2])
return dd1
chosenR=0.001
for b in O.bodies:
aa=[]
bb=[]
cc=[]
dd=[]
if not isinstance(b.shape,Polyhedra): # skip non-polyhedra bodies
continue
vs = [b.state.ori*v for v in b.shape.v] # vertices in global coords
face2=b.shape.GetSurfaces()
id1=0
while id1<len(face2):
face11=face2[id1]
if len(face11)>2:
vec1=vs[face11[2]]-vs[face11[1]]; vec1.normalize()
vec2=vs[face11[0]]-vs[face11[1]]; vec2.normalize() #Normalize this object in-place.
vects=vec1.cross(vec2); vects.normalize()
dvalue2=dvalue(vects,vs[face11[0]]) # Some dvalue2 values return equal to 0. Check this part of your script once more.
dv=dvalue2-chosenR
aa.append(vects[0])
bb.append(vects[1])
cc.append(vects[2])
dd.append(dv)
id1=id1+1
I also found that there is a bug with Vector3
? Just as this picture shows. I don't know if it is relate to my question.
What I'm generating is an icosahedron. VV contains all of its vertex coordinates. While the number of PB vertices I found with O.bodies[1].shape.vertices is 102. It has confused me.
Version:Yade 2024.02 and Ubuntu 20.04.6.
cheers,
Yunzhu