← Back to team overview

yade-users team mailing list archive

Re: [Question #692660]: Heterogeneous complex material shape

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

as discussed in mentioned question/256038, you can use pack.inGtsSurface for this purpose:
###
import gts
from yade import pack
horseFile = "/home/honzik/programs/yade/trunk/examples/gts-horse/horse.coarse.gts"
with open(horseFile) as f:
   horse = gts.read(f)
horse.scale(100,100,100)
O.bodies.append(pack.gtsSurface2Facets(horse))
s1 = sphere((0,0,0),1)
s2 = sphere((2,0,0),1)
s3 = sphere((4,0,0),1)
sphs = (s1,s2,s3)
O.bodies.append(sphs)

pred = pack.inGtsSurface(horse)
for sph in sphs:
   center = sph.state.pos
   radius = sph.shape.radius
   # "call" the predicate to test if a sphere/point is inside
   print("sphere ({},{}) inside: {}".format(center,radius,pred(center,radius)))
   print("center {} inside: {}".format(center,pred(center,0)))
###
The "left" sphere is "almost" inside, but along -x axis it is outside, therefore the result False.

the testing horse.coarse.gts is part of yade project [1].
The inGtsSurface testing is not exact [2], it checks 6 points (center +- radius along 3 axes) to be inside the mesh. You can test more points "manually" if desired (line center in the above example)

the gts surface can be loaded from file or constructed programatically.

cheers
Jan

[1] https://gitlab.com/yade-dev/trunk/-/blob/master/examples/gts-horse/horse.coarse.gts
[2] https://yade-dem.org/doc/yade.pack.html#yade._packPredicates.inGtsSurface.__init__

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