How do I programmatically check if compound shape is convex?

Typically: "How do I... ", "How can I... " questions
Post Reply
Adrian
Posts: 3
Joined: 22 Jun 2018, 23:03

How do I programmatically check if compound shape is convex?

Post by Adrian » 05 Oct 2018, 22:19

Hi!

Is there a way to programmatically find out whether a compound shape is convex?

I would like to scan my scene for shapes that are respondable and non-convex, since these types of shapes might slow down the simulation a lot. So I am trying to write an add-on that creates a list of all such shapes in the scene.

I know that I can use sim.getShapeGeomInfo() to check if a simple shape is convex, but this doesn't work for compound shapes. Alternatively, I could use sim.computeMassAndInertia(), which returns 0 if a compound shape is non-convex. However, it will also change the mass and inertia properties of the shape.

The only solution I can think of is to first duplicate each compound shape and then run sim.computeMassAndIntertia() on the duplicate. And then delete the duplicate again.

Is there a better way to simply check if a (compound) shape is convex?

Thank you!

fferri
Posts: 224
Joined: 09 Sep 2013, 19:28

Re: How do I programmatically check if compound shape is convex?

Post by fferri » 09 Oct 2018, 16:50

Not sure wether V-REP can natively do this.

The CGAL library has convexity checking routines.

If you want to use those routines, consider extending or basing your work off the Surface Reconstruction plugin, which already uses CGAL's functions.

coppelia
Site Admin
Posts: 6766
Joined: 14 Dec 2012, 00:25

Re: How do I programmatically check if compound shape is convex?

Post by coppelia » 10 Oct 2018, 07:13

Hello,

you can use sim.getObjectInt32Parameter with sim.shapeintparam_convex or sim.shapeintparam_compound.

Cheers

Adrian
Posts: 3
Joined: 22 Jun 2018, 23:03

Re: How do I programmatically check if compound shape is convex?

Post by Adrian » 11 Oct 2018, 15:15

Thank you!

Post Reply