I'm trying to understand a Monte-Carlo Laplace/Poisson PDE solver: http://www.cs.cmu.edu/~kmcrane/Projects/MonteCarloGeometryProcessing/paper.pdf
This method inspired by random-walks and ray-tracing has an advantage over FEM mesh methods in that it requires little to no mesh pre-processing. I do not expect great performance from Mathematica but that's okay - I'm just trying to play with concepts in the paper.
I want to perform a walk on spheres in Mathematica shown in this diagram in the paper:
Questions:
- Given a mesh such as
mesh = DiscretizeGraphics@ExampleData[{"Geometry3D", "Cow"}]
how do I get a random point $x_0$ on the interior of the mesh $\Omega$ ? I've triedRandomPoint
but it only gives points on the surface. - How do I find the closest point on the mesh surface $\partial\Omega$ to $x_0$ so I can then determine the radius $r_0$ of the first sphere?
Once I've got $x_0, r_0$ I can do RandomPoint
on the sphere to generate $x_1$ and Nest
this process until the sphere radius is below some threshold.
DiscretizeGraphics
byBoundaryDiscretizeGraphics
and useRegionNearest
.RegionNearest[mesh]
generates aRegionNearestFunction
that can (and should) be reused. $\endgroup$RandomPoint
$\endgroup$ExampleData[{"Geometry3D", "Triceratops"}, "BoundaryMeshRegion"]
instead (it is already aBoundaryMeshRegion
has `RegionDimension equal to 3). $\endgroup$rnf=RegionNearest[mesh]
, the pointx0=RandomPoint[mesh]
is correctly on the interior, but the nearest point I expected to lie on the surfacernf[x0]
is actually the same pointx0
$\endgroup$