getQHull and createMeshShape

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

getQHull and createMeshShape

Post by jwchang » 24 Jul 2018, 09:39

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
Site Admin
Posts: 6792
Joined: 14 Dec 2012, 00:25

Re: getQHull and createMeshShape

Post by coppelia » 24 Jul 2018, 13:09

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

Post by jwchang » 25 Jul 2018, 05:41

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
Site Admin
Posts: 6792
Joined: 14 Dec 2012, 00:25

Re: getQHull and createMeshShape

Post by coppelia » 25 Jul 2018, 07:21

sim.getQHull can't since it only generates a convex hull as the doc mentions.
Your problem is more to fit a surface to a collection of points. You have thousands of ways of doing this, depending on how tight or coarse you want the surface to be (in this picture it could be the left or right surface, or many others). Did you look at the surface reconstruction demo I mentioned? Have also a look at the surface reconstruction plugin.

Cheers

Post Reply