Finding the cross sectional area of a convex hull - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-08-20T10:55:48Z https://mathematica.stackexchange.com/feeds/question/137121 http://www.creativecommons.org/licenses/by-sa/3.0/rdf https://mathematica.stackexchange.com/q/137121 4 Finding the cross sectional area of a convex hull Doppler https://mathematica.stackexchange.com/users/45976 2017-02-06T20:05:34Z 2017-02-08T20:27:12Z <p>Suppose I have a convex hull as shown in orange. I have defined an axis for the hull by drawing an infinite line through the base, which I define, and it's centroid. I would like to know how I can find the cross sectional area of the convex hull shape at its widest point that is orthogonal to my line. </p> <p>For example, in the following figures, largest cross sectional area of the orange convex hull is quite more than the purple convex hull, which is skinnier. How can I quantify this?</p> <pre><code>data = Import["filepath", {"Data"}]; cone = ConvexHullMesh[data, MeshCellStyle -&gt; {{2, All} -&gt; Opacity[0.2, Orange]}]; base = First[data]; centroid=RegionCentroid[cone]; axesline=Graphics3D[{Thick,InfiniteLine[{base,centroid}]; Show[cone,axesline] </code></pre> <p><a href="https://i.stack.imgur.com/QozJd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QozJd.png" alt="thick cross sectional area"></a></p> <p><a href="https://i.stack.imgur.com/h2R3m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h2R3m.png" alt="example of thinner cone"></a></p> https://mathematica.stackexchange.com/questions/137121/-/137126#137126 11 Answer by Jason B. for Finding the cross sectional area of a convex hull Jason B. https://mathematica.stackexchange.com/users/9490 2017-02-06T20:50:23Z 2017-02-08T20:27:12Z <p>Here's my hack solution to the fact that <code>RegionIntersection[ &lt;3D mesh Region&gt;, InfinitePlane[...]]</code> does not evaluate. You need to get your cross section into the form of an <code>InfinitePlane</code>, then you find the lines which make up the intersection between the plane and the faces of the mesh region. Problem is now that these lines aren't in any order, so we take all the points making up the lines, and use <code>FindShortestTour</code> to put them in order, and finally make a <code>Polygon</code> out of these.</p> <pre><code>SeedRandom; region = ConvexHullMesh[ RandomReal[1, {14, 3}] ]; plane = InfinitePlane[{{1., 0.5, 1.}, {0, 0.25, 0}, {2, 0.5, 1}}]; RegionPlot3D[{region}, Axes -&gt; True, AxesLabel -&gt; {"x", "y", "z"}]~Show~Graphics3D[{Red, plane}] </code></pre> <p><img src="https://i.stack.imgur.com/CCLhR.png" alt="Mathematica graphics"></p> <p>Here we get the polygon,</p> <pre><code>crossSection = RegionIntersection[plane, #] &amp; /@ MeshPrimitives[region, 2] // DeleteCases[_EmptyRegion] // ReplaceAll[Line :&gt; Sequence] // Flatten[#, 1] &amp; // (#[[Last@FindShortestTour[#]]] &amp;) // Polygon; Graphics3D[crossSection] </code></pre> <p><img src="https://i.stack.imgur.com/GKgn3.png" alt="Mathematica graphics"></p> <p>Verify that this worked,</p> <pre><code>Show[ RegionPlot3D[region, PlotStyle -&gt; Opacity[0.5]], Graphics3D[{Red, crossSection}] ] </code></pre> <p><img src="https://i.stack.imgur.com/DsTtt.png" alt="Mathematica graphics"></p> <p>Then just get the area,</p> <pre><code>Area@crossSection (* 0.353513 *) </code></pre> <p>To get more to the exact question in the OP, if you wanted to get the cross section area when you have two points, one being the base, the other being the region centroid, you'd make up the infinite plane thusly</p> <pre><code>base = (*the origin, why not? *) {0,0,0}; point = RegionCentroid[region]; line = InfiniteLine[{base,point}]; plane = Module[{vec1,vec2,vec3,a,b,c}, vec1=Normalize[base-point]; vec2={a,b,c}/.First@FindInstance[{a,b,c}.vec1==0.&amp;&amp;Norm[{a,b,c}]==1,{a,b,c}]; vec3=Cross[vec1,vec2]; InfinitePlane[point,{vec2,vec3}] ]; crossSection = RegionIntersection[plane, #] &amp; /@ MeshPrimitives[region, 2] // DeleteCases[_EmptyRegion] // ReplaceAll[Line :&gt; Sequence] // Flatten[#, 1] &amp; // (#[[Last@FindShortestTour[#]]] &amp;) // Polygon; Show[ RegionPlot3D[region, PlotStyle -&gt; Opacity[0.5]], Graphics3D[{ Red, EdgeForm[Directive[Thick,Black]], crossSection, Yellow,Sphere[point,.02], Black,AbsoluteThickness,line} ],Boxed-&gt;False ] </code></pre> <p><img src="https://i.stack.imgur.com/6LBW6.png" alt="Mathematica graphics"></p> <pre><code>Area@crossSection (* 0.529433 *) </code></pre>