← Back to team overview

yade-users team mailing list archive

Re: [Question #681341]: Move or scale a facet

 

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

Jan Stránský posted a new comment:
Hello,

> just multiplying a scaling factor is not feasible. The vertice
coordinates can not be changed directly

the vertices can be changes, but they must be set at once (similar to
setting one component of b.state.pos)

###
b = Body()
print b.state.pos
b.state.pos[0] = 1 # does not work
print b.state.pos
b.state.pos  = (1,0,0) # works
print b.state.pos
###

for your case:
###
v1 =(0,0,0)
v2 = (1,0,0)
v3 =(1,1,0)
f1 = facet((v1,v2,v3),wire=False)
O.bodies.append(f1)
print f1.shape.vertices
print [f1.state.pos + f1.state.ori*v for v in f1.shape.vertices]

# move facet 1
f1 = O.bodies[0]
mv = (1,0,0)
f1.state.pos += mv
print f1.shape.vertices
print [f1.state.pos + f1.state.ori*v for v in f1.shape.vertices]

# scale vertices
vs = f1.shape.vertices # original vertices
vs = [v*0.5 for v in vs] # scaled vertices
f1.shape.vertices = vs # vertices set at once
print f1.shape.vertices
print [f1.state.pos + f1.state.ori*v for v in f1.shape.vertices]
###

cheers
Jan

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