## getQHull and createMeshShape

Typically: "How do I... ", "How can I... " questions
jwchang
Posts: 3
Joined: 22 Jun 2018, 10:53

### getQHull and createMeshShape

I want to create a range which can surround specified points. I use getQHull to retrieve the convex hull mesh from the specified vertices and then use createMeshShape to make a mesh shape. It should be concave on the left side, but the two points on x=0 are connected like this.
https://imgur.com/R6hH38Q https://imgur.com/9LvIg4V
How can I make it concave? Are there any ways or other functions can do that?
Following is my simple code.

Code: Select all

``````if (sim_call_type==sim.syscb_init) then
local points={0,1,0.2,0.5,0.7,0.2,1,0,0.2,0.5,-0.7,0.2,0,-1,0.2,0.2,-0.2,0.2,0.5,0,0.2,0.2,0.2,0.2, 0,1,0,0.5,0.7,0,1,0,0,0.5,-0.7,0,0,-1,0,0.2,-0.2,0,0.5,0,0,0.2,0.2,0}

local vertices,indices=sim.getQHull(points)
local shape=sim.createMeshShape(3,0,vertices,indices)
sim.reorientShapeBoundingBox(shape,-1)
sim.setShapeColor(shape,nil,0,{1,0,1})
sim.setShapeColor(shape,nil,4,{0.2})
end``````
Thanks.

coppelia
Posts: 6914
Joined: 14 Dec 2012, 00:25

### Re: getQHull and createMeshShape

Hello,

I don't understand what you are trying to achieve. The function sim.getQHull clearly says that it generates convex hulls, not concave hulls, which is is more a problem of surface reconstruction. Have a look at the demo scene navigationWithinAPointCloud.ttt that allows you to turn a point cloud into a mesh

Cheers

jwchang
Posts: 3
Joined: 22 Jun 2018, 10:53

### Re: getQHull and createMeshShape

I find a website figure to explain what I mean.
https://www.semanticscholar.org/paper/A ... b/figure/2
In this figure,(a) surround all points, which is the shape of the function sim.getQHull just forms. The shape of (b) is what I want, and its line is along with boundary of points. So can sim.getQHull or other functions/ways form the shape of (b)?

coppelia