TransWikia.com

Finding plane equations of planes in a convex hull

Mathematica Asked by Samvid Mistry on October 1, 2021

I’m new to mathematica and I need to get the equations for the set of planes which are part of a convex hull that I have calculated using ConvexHullMesh. It is a convex polyhedron. I tried searching quite a bit but there does not seem to be any mention of this. Any help is appreciated.

For the reference, here’s the code for convex hull

pts = {{-0.00033004023134713956, 0, 0},{-0.00033004023134713956, -0.001, 0},
{0.00033004023134713956, -0.001, 0},{0.00033004023134713956, -0.00033004023134713956, 0},
{0,0,0},{-0.00033004023134713956, 0.001, -0.00033004023134713956},{0.00033004023134713956, 
0.001, 0.00033004023134713956},{0.00033004023134713956, 0, 0.00033004023134713956},
{-0.00033004023134713956, 0.00033004023134713956, -0.00033004023134713956},{0,0,0},
{-0.00033004023134713956, 0, 0},{-0.00033004023134713956, 0.00033004023134713956, 
-0.00033004023134713956},{0,0,0},{0.00033004023134713956, 0, 0.00033004023134713956},
{0.00033004023134713956, -0.00033004023134713956, 0},{0,0,0}};

ConvexHullMesh[pts, AxesLabel -> {"E(y)", "y", "E(z)"}]

2 Answers

You can get equations for each polygon membership like this:

eqns = FullSimplify[RegionMember[#, {x, y, z}]] & /@ MeshPrimitives[cvx, 2]

This has inequalities to constrain each plane to the triangular face of each polygon. You can throw these away just leaving the equations of the planes:

planeEqns = DeleteCases[eqns, (_ >= _) | (_ <= _), Infinity]

(* or better, you could do: *)
planeEqns = Select[Flatten[eqns /. And -> List], Head[#] === Equal &]

Result:

{1. x == 0.00033004 + 2. z, 0.001 + 1. y + 4.02993 z == 0, 
 0.00033004 + 1. x == 0, 0.001 + 1. y == 3.02993 z, 
 1. x == 0.00033004, 
 1. x + 2.50817*10^-16 z == 0.00033004 + 2.18777*10^-16 y, 
 1. x + 0.248143 y == 0.000248143 + 1. z, 
 0.00033004 + 1. x == 0.33004 y + 1. z, 
 0.00033004 + 1. x + 2.27638*10^-16 y + 4.78885*10^-16 z == 0, 
 1. x + 1.09024*10^-16 y == 0.00033004 + 2. z, 
 0.00033004 + 1. x + 2.79408*10^-17 y == 2. z, 
 0.00033004 + 1. x == 2. z}

Then you could convert this into a matrix form $A hat{x}+b=mathbf{0}$ if you needed to use it in something like a linear programming problem:

(* use chop to throw away some very small values if desired *)
mtxs = Chop@Normal@CoefficientArrays[planeEqns /. Equal -> Subtract, {x, y, z}]

Correct answer by flinty on October 1, 2021

Here is a way to get the triangle means and the normals of the triangular faces using ToBoundaryMesh. With that information, you should be able to obtain an equation of a plane.

Needs["NDSolve`FEM`"]
pts = {{-0.00033004023134713956, 0, 
    0}, {-0.00033004023134713956, -0.001, 
    0}, {0.00033004023134713956, -0.001, 
    0}, {0.00033004023134713956, -0.00033004023134713956, 0}, {0, 0, 
    0}, {-0.00033004023134713956, 
    0.001, -0.00033004023134713956}, {0.00033004023134713956, 0.001, 
    0.00033004023134713956}, {0.00033004023134713956, 0, 
    0.00033004023134713956}, {-0.00033004023134713956, 
    0.00033004023134713956, -0.00033004023134713956}, {0, 0, 
    0}, {-0.00033004023134713956, 0, 0}, {-0.00033004023134713956, 
    0.00033004023134713956, -0.00033004023134713956}, {0, 0, 
    0}, {0.00033004023134713956, 0, 
    0.00033004023134713956}, {0.00033004023134713956, 
-0.00033004023134713956, 0}, {0, 0, 0}};

chull = ConvexHullMesh[pts, AxesLabel -> {"E(y)", "y", "E(z)"}]
bmesh = ToBoundaryMesh[chull];
groups = bmesh["BoundaryElementMarkerUnion"];
temp = Most[Range[0, 1, 1/(Length[groups])]];
colors = ColorData["BrightBands"][#] & /@ temp;
Short[bn = bmesh["BoundaryNormals"]];
mean = Mean /@ GetElementCoordinates[bmesh["Coordinates"], #] & /@ 
   ElementIncidents[bmesh["BoundaryElements"]];
Show[
 bmesh["Wireframe"["MeshElementStyle" -> FaceForm /@ colors]],
 Graphics3D[
  MapThread[
   Arrow[{#1, #2}] &, {Join @@ mean, Join @@ (bn/2000 + mean)}]]]

Triangle Normals

The following should retrieve the equations of the plane normals (note that some are coplanar):

Simplify[({x, y, z} - #[[1]]).#[[2]] == 0] & /@ 
  Transpose@{mean[[1]], bn[[1]]} // MatrixForm

Plane Equations

Answered by Tim Laska on October 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP