Mathematica has documentation for triangulating regions bounded by curves using e.g. TriangulateMesh. This is very useful for the work that I (aspire to) do drawing pictures of complicated surfaces with integral representations. I triangulate a region, solve my problem numerically on the vertices, and then I can make a graph over the triangulated region out of triangles which will closely resemble a solution, if one exists.
But when I want to start this numerical scheme, I will want to use a value that I know as initial data. Unfortunately, Mathematica will not give me a triangulation which is guaranteed to have any specific points as vertices, which is annoying.
Can I use TriangulateMesh to incorporate a given point? For example, suppose I want to triangulate something simple, like a disk. How can I guarantee that the origin appears as a vertex?
There is a related question here, about adding specific edges.. I think this is more complicated than I need, since I am not (at the moment, at least) I am only concerned with adding points, and letting Mathematica draw any edges it wants.
Update, some months later: I am revisiting this question because I have once again encountered this problem, and this time made some progress myself, but the progress has in turn lead to more difficulties.
Suppose I have a MeshRegion called m
consisting of vertices, edges, and faces in a planar region. This is the kind of thing naturally made by TriangulateMesh
, for example. Here is a way to add a specific point to the region.
First, retrieve the list vertices = Apply[Complex, MeshCoordinates[m], 1];
Define NewVertices=Append[vertices,NewPoint]
. Then, find the cell which contains the vertex. In my relatively simple case, I just use Show
to see where the point is and find the cell by zooming in. Then make a new MeshRegion by writing:
NewMesh = MeshRegion[ReIm[NewVertices],Join[MeshCells[m, 1], {Line[{453, 645}], Line[{459, 645}], Line[{505, 645}]}]]
Numbers are chosen from my specific example but don't mean anything here. This works great, if you only want a mesh skeleton of dimension $1$. Problem is, if I try to go further and add to this code stuff like ,Join[MeshCells[m,2],{Polygon[{a,b,c}]}
, then Mathematica complains and will not do this. In fact, it even complains if I don't try to Join
anything at all, and just try to incorporate any of the old faces. In particular, its complaint is nonopt
, it expects options where my 2-cells are supposed to go, even though the documentation seems to suggest I can have cells in any dimension.
What is the cause of the error, and how do I fill in my skeleton? I'd like to keep using TriangulateMesh
if possible.