Sometimes, you can tell Mathematica knows something internally, possibly because it visualizes the known quantities for you, but can't figure out how to get it to tell you them explicitly. I'm having such a problem with MeshRegion and certain PlotThemes.

Say you have a mesh - say this one from the documentation:

 myMesh = 
   MeshRegion[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}},
    {Tetrahedron[{1, 2, 3, 5}], Tetrahedron[{1, 3, 4, 5}]}];

You can then request to see the normal vectors of each face using PlotTheme -> "FaceNormals" like this:

 MeshRegion[myMesh, PlotTheme -> "FaceNormals"]

This produces the requested tetrahedron with small, black lines visualizing the face normal vectors.

However, I cannot seem to find how to have Mathematica print this information explicitly. I have tried using MeshRegion[myMesh, PlotTheme -> "FaceNormals"] // InputForm and deducing from this, but it simply repeated that my requested PlotTheme is "FaceNormals", without the numerical information for the vector visualizations.

I have dug for it, but feel I may be missing some portion of the documentation where this is stated. Does anyone know how to - either by extracting it from Mathematica's internal workings, or simply mathematically in an algorithmic fashion - produce the "FaceNormals" of any arbitrary mesh?

My actual meshes aren't so simple as they vary in shape and have upwards of 1000 triangular faces or more, rather than the 4 here, but the PlotTheme itself produces the "FaceNormals" with no issue, so I know it can be done and has internally...

  • 3
    $\begingroup$ See mathematica.stackexchange.com/a/130356/4999 for Region`Mesh`MeshCellNormals $\endgroup$ – Michael E2 Feb 26 '18 at 0:22
  • 2
    $\begingroup$ also mr= MeshRegion[myMesh, PlotTheme -> "FaceNormals"]; facenormals=Cases[Normal[Show@mr], _Line, Infinity]; Show[mr, Graphics3D[{Red, Thick,facenormals}]] $\endgroup$ – kglr Feb 26 '18 at 1:15
mr = MeshRegion[myMesh, PlotTheme -> "FaceNormals"];
fnormals = Cases[Normal[Show @ mr], _Line, Infinity];

Show[mr, Graphics3D[{Red, Thick, fnormals}]]

enter image description here

Show[mr, Graphics3D[{Red, Thick, fnormals /. Line[{x_, y_}] :> Line[{x, x + 10 (y-x)}]}]]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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