# MeshFunctions::invmeshf that resists other solutions

I'm trying to base mesh on the slope of the function. That's why there is a Cross of two partial derivatives.

With[{R = Function[If[Abs[#1] < \[Pi]/4, 1, Sec[Abs[#1] - \[Pi]/4]]]},
With[{F =
Function @@ {{\[CurlyPhi],
h}, {Sin[\[CurlyPhi]] R[\[CurlyPhi], h],
Cos[\[CurlyPhi]] R[\[CurlyPhi], h], h}}},
ParametricPlot3D[
F[\[CurlyPhi], h], {\[CurlyPhi], -(\[Pi]/2), \[Pi]/2}, {h, -1,
1}, MeshFunctions -> #1,
Mesh -> {{0}}] &@{Function @@ {{\[CurlyPhi], h},
Norm[{#1, #2, #3}] & @@ Cross[\!$$\*SubscriptBox[\(\[PartialD]$$, $$h$$]$$F[\[CurlyPhi], h]$$\), \!$$\*SubscriptBox[\(\[PartialD]$$, $$\[CurlyPhi]$$]$$F[\[CurlyPhi], h]$$\)]}}]]


The graph is plotted, but the mesh is not, and there is an error message:

MeshFunctions::invmeshf: "MeshFunctions->Function[{φ,h},Sqrt[Abs[Cos[<<1>>] If[<<3>>]+If[<<3>>] Sin[<<1>>]]^2+Abs[-Cos[<<1>>] If[<<3>>]+If[<<3>>] Sin[<<1>>]]^2]] must be a pure function or a list of pure functions."


Quite suddenly, when R is replaced by Function, the error disappears. But I don't need 1.

I tried renaming the arguments to the mesh function (to no avail), I turned the option into an argument to ParametricPlot3D& (to no avail), I turned Function[] into Function@@{} (to no avail). Now I'm at a loss.

• Should be MeshFunctions -> {#1 &} Jul 18, 2021 at 23:45
• @cvgmt You missed the whole point. This is not a newbie question. Jul 18, 2021 at 23:58

Sorry for my careless.

Maybe Abs can't be differential in Mathematica,so we have to use RealAbs instead.

And it seems that we need to set  Mesh -> {{1}}.

With[{R = If[RealAbs[#1] < Pi/4, 1, Sec[RealAbs[#1] - Pi/4]] & },
With[{F =
Function @@ {{φ,
h}, {Sin[φ]*R[φ, h],
Cos[φ]*R[φ, h], h}}},
(ParametricPlot3D[
F[φ, h], {φ, -(Pi/2), Pi/2}, {h, -1, 1},
MeshFunctions -> #1, MeshStyle -> {Thick, Red},
Mesh -> {{1}}] & )[
{Function @@ {{φ, h}, (Norm[{#1, #2, #3}] & ) @@
Cross[D[F[φ, h], h],
D[F[φ, h], φ]]}}]]] • This works, and it's even backportable to V9 (by adding a definition for RealAbs). Thanks! Jul 19, 2021 at 13:54
• Also I had to use Function[{#4, #5} /. {φ_, h_} :> val] /. val ->#3/Norm[{#1, #2, #3}] & @@ Cross[], but that's unrelated to the error message. Jul 27, 2021 at 9:14