# Restricting Plot3D to an area inside parametrically defined region

I have a region specified as a simple closed curve, suitable for ParametricPlot (as in this question).

What is the easiest way to restrict 3D plot to only plot points inside this region?

An example application is here -- I'm plotting resolvent and range of matrix as separate Plot3D and ParametricPlot, but I'd like to combine them into a single Plot3D by using RegionFunction argument. However, that takes a region membership function, but I instead have a curve of the boundary.

ClearAll["Global*"];
n = 3;

mat = RotateLeft@IdentityMatrix[n];
mat[[n, 1]] = eps;
mat
];

fval[mat_?SquareMatrixQ, t_?NumericQ] /;
InternalEffectivePrecision[mat] < \[Infinity] ||
InexactNumberQ[t] :=
Module[{tm, v}, tm = (# + ConjugateTranspose[#])/2 &[mat Exp[I t]];
v = Quiet[
Check[First[
Eigenvectors[tm, 1,
Method -> {"Arnoldi", "Criteria" -> "RealPart"}]],
MaximalBy[Transpose[Eigensystem[tm]], First][[1, -1]],
Eigenvectors::arall]];
(Conjugate[v] . mat . v)/(Conjugate[v] . v)];

pr = {{-1, 1}, {-1, 1}};

epsVals = {0.01, .1, .5, .9};

rangePlot[mat_] :=
With[{eigs = Eigenvalues[mat]},
ParametricPlot[ReIm[fval[mat, t]], {t, 0, 2 \[Pi]},
Epilog -> {AbsolutePointSize[10], ColorData[97, 2],
Point[ReIm[eigs]]}, PlotRange -> pr]];

resolventPlot[mat_] := Module[{},
eigs = Eigenvalues[mat];
c = Norm[mat];
n = Length[mat];
spectraPlot =
Plot3D[-c Log10[
First[SingularValueList[
mat - SparseArray[Band[{1, 1}] -> x + I y, {n, n}], -1,
Method -> "Arnoldi", Tolerance -> 0]]], {x, -2, 4}, {y, -4,
4}, AspectRatio -> Automatic, PlotRange -> {-1, 1},
MeshFunctions -> {#3 &}, Boxed -> False, Axes -> False
]
];

Print["Matrices"];
Print["Resolvents"];
Print["Numeric ranges"];


By

regs = BoundaryDiscretizeGraphics /@ fig2ds


we get the 4 regions.

reg = BoundaryDiscretizeGraphics@ParametricPlot[ReIm[fval[mat, t]] // Evaluate, {t, 0, 2 π}];
regm = RegionMember@reg;


and set RegionFunction -> Function[{x, y, z}, regm@{x, y}]

Clear[resolventPlot2];
resolventPlot2[mat_] := Module[{}, eigs = Eigenvalues[mat];
c = Norm[mat];
n = Length[mat];
reg = BoundaryDiscretizeGraphics@
ParametricPlot[ReIm[fval[mat, t]] // Evaluate, {t, 0, 2 π}];
regm = RegionMember@reg;
spectraPlot =
Plot3D[-c Log10[
First[SingularValueList[
mat - SparseArray[Band[{1, 1}] -> x + I y, {n, n}], -1,
Method -> "Arnoldi", Tolerance -> 0]]], {x, -2, 4}, {y, -4,
4}, AspectRatio -> Automatic, PlotRange -> {-1, 1},
MeshFunctions -> {#3 &}, Boxed -> False, Axes -> False,
RegionFunction -> Function[{x, y, z}, regm@{x, y}]]]

• Thanks for the find, BoundaryDiscretizeGraphics seems like the trick Jul 27, 2023 at 0:07