1
$\begingroup$

This looks like a simple question with the answer to be easily found, but unfortunately I could not find it either on the web or in the documentation browser.

Let us assume we have a MeshRegion meshx with vertices vlis = MeshCoordinates[meshx].

So vlis is a list of 2D points (in my case). Suppose I have a second list fvlis of the same length containing real numbers (to fix ideas, could be vectors too). Then fvlis defines on meshx a piecewise linear function f[x,y] (written in Mathematica notation). The function should be defined for all points that are in the region of meshx.

Now the problem is: How can I actually get this function f[x,y]? Is there a simple inbuilt function for this, or is it necessary to write a piece of code for it? If the latter, how could one do it?

$\endgroup$
8
  • $\begingroup$ Should f[x, y] only be defined on the mesh vertices, and therefore return unevaluated for other values of $(x,y)$, or do you want an Interpolation? $\endgroup$ Commented Jan 3, 2023 at 19:50
  • $\begingroup$ @MarcoB I want a (piecewise linear, for example) interpolation. (I edited the post for clarification). $\endgroup$ Commented Jan 3, 2023 at 19:51
  • 2
    $\begingroup$ Then Interpolation[Transpose[{vlis, fvlis}] should work $\endgroup$ Commented Jan 3, 2023 at 19:54
  • 2
    $\begingroup$ Perhaps ElementMeshInterpolation[] is what you are looking for $\endgroup$ Commented Jan 3, 2023 at 20:14
  • $\begingroup$ @Ulrich Neumann The solution withInterpolation worked for me, but of course it is always good to have several tools at hand. What could be the advantages of ElementMeshInterpolation? Is it faster? $\endgroup$ Commented Jan 3, 2023 at 20:34

1 Answer 1

2
$\begingroup$

I used the hints in the comments to write the following code (excerpt from my notebook):

enter image description here

With a little more calculation this allowed me to generate:

enter image description here

Explanation: result.off is a flat image of quartic-R11.off, a so called (conformal) surface mesh parametrization. I computed this externally with

CGAL Planar Parameterization of triangulated surface meshes

The vertices in meshx and workMeshcorrespond to each other in their respective sequential orders. The map phiMap1 is the final map that parameterizes workMesh as the image of meshx2d.

In a part of the calculation not shown, I generated a rectangular array of grid points over meshx2d and projected them with phiMap1 onto the quartic surface. For each of the image points I subtracted a ball of suitable radius from the quartic surface. This gave me a multiply punctured surface, where the holes are placed (in my eyes) in an aesthetically pleasing way.

Of course there is still much to improve and room for further experimentation, but it was a successfull first step.

$\endgroup$
5
  • 1
    $\begingroup$ Thank you for putting together this answer! Please include the code snippets as formatted text rather than just as images. $\endgroup$ Commented Jan 4, 2023 at 19:31
  • $\begingroup$ @MarcoB Is there a special Mathematica menu point to export selected cells as text or does one do simply copy and paste (with the system clipboard)? $\endgroup$ Commented Jan 4, 2023 at 19:35
  • 1
    $\begingroup$ In most cases copy/paste is fine, but take a look at the suggestions here: How to copy code from Mathematica so it looks good on this site. $\endgroup$ Commented Jan 4, 2023 at 22:45
  • $\begingroup$ Click on the blue circle-i for more information on how to fix the issue mentioned in the message. $\endgroup$ Commented Jan 5, 2023 at 6:41
  • $\begingroup$ Unfortunately, you did not provide the code for your answer, but I have made something similar for your other question here $\endgroup$ Commented Jan 12, 2023 at 8:38

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.