7
$\begingroup$

I ran in the last few days into a problem which I was afraid I couldn't solve: I use a set of 12 points in 3D to define a region and test whether and if how many other points lie inside this region. I used ConvexHull[] on the 12 points to define the region and then simply RegionMember[] for the test.

However, for certain positions of these 12 points the kernel just shut down, without running into RAM problems. Is this a known issue? I use here Mathematica 10.2. Just to be able to test this here is an example code which kills everytime my kernel:

(*8x 12points after a lengthy computation*)
test={{{1.`, 1.`, 5333.333333333333`}, {1.`, 800.`,5333.333333333333`},{600.5`, 400.5`, 0.`}, {600.5`, 400.5`,5333.333333333333`},{1200.`,1.`,5333.333333333333`}, {1200.`, 800.`, 5333.333333333333`},{58042.552333112566`, -38206.400563704345`, 19374.67514613655`},{58334.25743941619`, -38734.91563377405`, 18851.24324830685`}, {58525.314741500944`, -38713.1081147315`, 19545.52131899129`}, {58716.372043585696`, -38691.30059568895`,20239.79938967573`}, {59008.07714988933`, -39219.81566575865`, 19716.36749184603`}, {62483.79825981317`, -35344.65017352293`,18350.38794651614`}},
{{1.`, 1.`,5333.333333333333`}, {1.`, 800.`,5333.333333333333`}, {600.5`,400.5`, 0.`}, {600.5`, 400.5`, 5333.333333333333`}, {1200.`, 1.`,5333.333333333333`}, {1200.`, 800.`, 5333.333333333333`}, {25869.10601275226`,-20033.469429356493`, 10006.45364321929`},{26269.363331591725`, -20404.815082668127`,9423.103418669753`}, {26554.859683382878`, -20246.27216215559`,10065.253304186597`}, {26840.35603517403`, -20087.729241643054`,10707.403189703442`}, {27240.613354013494`, -20459.074894954687`,10124.052965153904`}, {28180.172063134924`, -15530.123404949865`,8178.259660165485`}},
{{1.`, 1.`,-5333.333333333333`}, {1.`, 800.`, -5333.333333333333`}, {600.5`,400.5`, -5333.333333333333`}, {600.5`, 400.5`, 0.`}, {1200.`, 1.`, -5333.333333333333`}, {1200.`, 800.`, -5333.333333333333`}, {62483.79825981317`,-35344.65017352293`, -18350.38794651614`}, {62743.673933721235`,-30067.648628019182`, -19374.67514613655`}, {63347.238653729575`,-30056.261042864524`, -18851.24324830685`}, {63423.809574513405`,-30232.656492513917`, -19545.52131899129`}, {63500.380495297235`,-30409.05194216331`, -20239.79938967573`}, {64103.945215305575`,-30397.664357008656`, -19716.36749184603`}},
{{1.`, 1.`, -5333.333333333333`}, {1.`, 800.`, -5333.333333333333`}, {600.5`, 400.5`, -5333.333333333333`}, {600.5`, 400.5`, 0.`}, {1200.`, 1.`, -5333.333333333333`}, {1200.`,800.`, -5333.333333333333`}, {28180.172063134924`, -15530.123404949865`, -8178.259660165485`}, {30926.38377214352`, -11278.127055695275`, -10006.45364321929`}, {31448.041575476618`, -11439.299794518214`, -9423.10341866975`}, {31453.354516395335`, -11765.820539938006`, -10065.253304186597`}, {31458.66745731405`, -12092.341285357797`, -10707.403189703442`}, {31980.32526064715`, -12253.514024180738`, -10124.052965153904`}}, 
{{1.`, 1.`,5333.333333333333`}, {1.`, 800.`, 5333.333333333333`}, {600.5`, 400.5`, 0.`}, {600.5`, 400.5`, 5333.333333333333`}, {1200.`, 1.`, 5333.333333333333`}, {1200.`, 800.`, 5333.333333333333`}, {62483.79825981317`, -35344.65017352293`, 18350.38794651614`}, {65959.51936973701`, -31469.48468128722`, 16984.40840118625`}, {66251.22447604063`, -31997.999751356918`, 16460.976503356556`}, {66442.2817781254`, -31976.192232314366`, 17155.25457404099`}, {66633.33908021015`, -31954.384713271815`, 17849.532644725427`}, {66925.04418651378`, -32482.89978334152`, 17326.100746895732`}},
{{1.`, 1.`, 5333.333333333333`}, {1.`, 800.`, 5333.333333333333`}, {600.5`, 400.5`, 0.`}, {600.5`, 400.5`,5333.333333333333`}, {1200.`, 1.`, 5333.333333333333`}, {1200.`, 800.`, 5333.333333333333`}, {28180.172063134924`, -15530.123404949865`, 8178.259660165485`}, {29119.730772256356`, -10601.171914945044`, 6232.466355177065`}, {29519.988091095816`, -10972.517568256677`, 5649.116130627529`}, {29805.48444288697`, -10813.97464774414`, 6291.266016144374`}, {30090.980794678122`, -10655.431727231604`, 6933.4159016612175`}, {30491.238113517582`, -11026.777380543239`, 6350.06567711168`}},
{{1.`, 1.`, -5333.333333333333`}, {1.`, 800.`, -5333.333333333333`}, {600.5`,400.5`, -5333.333333333333`}, {600.5`, 400.5`, 0.`}, {1200.`, 1.`, -5333.333333333333`}, {1200.`, 800.`, -5333.333333333333`}, {60863.65130432076`,-40291.635990037204`, -16984.40840118625`}, {61467.21602432911`, -40280.24840488255`, -16460.976503356553`}, {61543.78694511293`, -40456.64385453195`, -17155.254574040995`}, {61620.35786589677`, -40633.039304181344`, -17849.53264472543`}, {62223.9225859051`, -40621.65171902669`, -17326.100746895736`}, {62483.79825981317`, -35344.65017352293`, -18350.38794651614`}},
{{1.`, 1.`, -5333.333333333333`}, {1.`, 800.`, -5333.333333333333`}, {600.5`, 400.5`, -5333.333333333333`}, {600.5`, 400.5`, 0.`}, {1200.`, 1.`, -5333.333333333333`}, {1200.`, 800.`, -5333.333333333333`}, {24380.018865622696`, -18806.73278571899`, -6232.466355177068`}, {24901.6766689558`, -18967.90552454193`, -5649.116130627528`}, {24906.989609874516`, -19294.426269961717`, -6291.266016144374`}, {24912.302550793233`, -19620.947015381513`, -6933.41590166122`}, {25433.96035412633`, -19782.119754204454`, -6350.065677111683`}, {28180.172063134924`, -15530.123404949865`, -8178.259660165485`}}};

Now if I do

ConvexHullMesh/@test

it kills my kernel. If I do it indiviually I found out that it is the third array which seems to kill the kernel, the rest is calced just fine:

ConvexHullMesh[test[[3]]]

After isolating the problem I finally found the solution: Michael E2 mentioned in this post: see answer by Michael E2 that the ConvexHull is basically the BoundaryMesh of the DelaunayMesh of the points. So if I do

BoundaryMesh[DelaunayMesh[test[[3]]]]

or this

BoundaryMesh[DelaunayMesh[#]] & /@ test

it works and I can test for RegionMember, e.g. by

 RegionMember[#, {1.`, 800.`, -5333.333333333333`}] & /@ regs

I am positive that this behaviour of ConvexHullMesh is not intended.

$\endgroup$
6
  • $\begingroup$ I can confirm that the third element of test will crash my kernel. If you run Point@test[[3]] // Graphics3D it seems likely that the issue is that it's so long and narrow. Maybe the algorithm gets trapped trying to find solutions. $\endgroup$
    – b3m2a1
    Apr 10, 2018 at 1:52
  • $\begingroup$ I'll let you off the hook for this, since I have confirmed it, but next time, please don't jump the gun and use the bugs tag until other people have confirmed it. $\endgroup$ Apr 10, 2018 at 1:55
  • $\begingroup$ This happens also in version 11.3. Curiously, it works when I scale test[[3]] by 1/10 before calling ConvexHullMesh... $\endgroup$ Apr 10, 2018 at 7:22
  • 1
    $\begingroup$ Filed as [CASE:4042640]. $\endgroup$ Apr 10, 2018 at 7:42
  • 1
    $\begingroup$ Yes, just ask the question like you would normally do, and let someone else add the bugs tag on your behalf after confirmation. This is all discussed here and other meta threads. $\endgroup$ Apr 10, 2018 at 8:45

1 Answer 1

4
$\begingroup$

First I supposed that it had to be an uncatched error in the TetGen library for the kernel quits without warning. However, using TetGenLink directly seems to work and may serve as a workaround until ConvexHullMesh is fixed.

Needs["TetGenLink`"];
myConvexHullMesh[args__] := Module[{pts, triangles},
  {pts, triangles} = TetGenConvexHull[args];
  BoundaryMeshRegion[pts, Triangle[triangles]]
  ]

This is also a bit faster than BoundaryMesh@*DelaunayMesh since it skips the tetrahedralization.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.