yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #19934
Re: [Question #681341]: Move or scale a facet
Question #681341 on Yade changed:
https://answers.launchpad.net/yade/+question/681341
Chareyre posted a new comment:
Hi,
If your plan is to have deforming facets (over time) scaling will not work
since time integration for facets assume a rigid body.
If it is your case PFacets should be considered since it reflects nodes
motion across the facet area.
If scaling is just a way to set an initial geometry then the above is ok.
Bruno
Le mer. 12 juin 2019 17:43, gaoxuesong <question681341@xxxxxxxxxxxxxxxxxxxxx>
a écrit :
> Question #681341 on Yade changed:
> https://answers.launchpad.net/yade/+question/681341
>
> Status: Answered => Solved
>
> gaoxuesong confirmed that the question is solved:
> Thanks. I have tried to move and scale a facet. For moving a facet, just
> changing the position is feasible. But for scaling a facet, just
> multiplying a scaling factor is not feasible. The vertice coordinates can
> not be changed directly, like the tuple and string in python, i think.
> Following is the code i used,
>
> from yade import qt
> c = qt.Controller()
> O.bodies.clear()
> ### 2 initial facet ###
> v1 =(0,0,0)
> v2 = (1,0,0)
> v3 =(1,1,0)
> f1 = facet((v1,v2,v3),wire=False)
> O.bodies.append(f1)
> v1 =(2,0,0)
> v2 = (3,0,0)
> v3 =(3,1,0)
> f1 = facet((v1,v2,v3),wire=False)
> O.bodies.append(f1)
>
> ## move facet 1
> fcet1 = O.bodies[0]
> mv = (1,0,0)
> fcet1.state.pos += mv
> ## succeed ###
> ## scale vertices
> for ev in fcet1.shape.vertices:
> for i in range(3):
> ev[i] *= 0.5
> ## failed, the vertices can not be changed
> ## then try to construct a new facet using the scaled and translated
> vertices
> vg = []
> for ev in fcet1.shape.vertices:
> vgi = fcet1.state.pos+fcet1.state.ori*ev ## global coordinates
> vg.append(vgi)
> print(vg)
> for each in vg:
> for i in range(3):
> each[i] *= 0.5
> if i == 1: ## translate in y direction by 2.0
> each[i] += 2.0
> print(vg)
> ## construct the new facet and remove the old one
> f1 = facet((vg[0],vg[1],vg[2]),wire=False)
> O.bodies.append(f1)
> O.bodies.erase(fcet1.id)
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
>
>
--
You received this question notification because your team yade-users is
an answer contact for Yade.