I'm trying to construct a BoundaryMeshRegion from a set of 3D surfaces generated using ParametricPlot3D. Here's my workflow:
- I created several
ParametricPlot3D
surfaces using equations of the form:
ParametricPlot3D[{fx, fy, fz}, {u, umin, umax}, {v, vmin, vmax}]
In this case, u
represents the parameter for each surface. However, for my surfaces, the parameter u
(called t
in my code) differs in its range across some surfaces. Specifically:
- The
t
range for two of the surfaces is the same. - For the other two surfaces, the
t
range is different.
- I extracted points, lines, and polygons from the plots using
Cases
. - Attempted to create a
BoundaryMeshRegion
by combining the extracted data.
2D Grapics:
a = ParametricPlot[{2 Cos[t], 2 Sin[t]}, {t, 0, Pi}, PlotRange -> All];
b = ParametricPlot[{4 + 2 Cos[t], 2 Sin[t]}, {t, Pi, 2 Pi},
PlotRange -> All];
c = ParametricPlot[{8 + 2 Cos[t], 2 Sin[t]}, {t, 0, Pi}];
d = ParametricPlot[{4 + 6 Cos[t], 6 Sin[t]}, {t, Pi, 2 Pi},
PlotRange -> All];
3D Grapics:
However, I get the error:
BoundaryMeshRegion::coplnr: The vertices in the polygon [...] are not coplanar.
Here’s a simplified version of my code:
(* Parameters *)
wrap = 4 \[Pi];
P1 = 100;
P2 = 20;
P = P1 + ((P2 - P1)/wrap)*t;
L = 1/(2 Pi)*Integrate[P, {t, 0, \[Phi]r}];
(* Transformation Matrix *)
M = ({
{Cos[\[Phi]r], -Sin[\[Phi]r], 0, 0},
{Sin[\[Phi]r], Cos[\[Phi]r], 0, 0},
{0, 0, 1, L},
{0, 0, 0, 1}
});
(* Parametric Equations *)
{X[1], Y[1]} = {2 Cos[t], 2 Sin[t]} /. \[Phi]r -> wrap;
{X[2], Y[2]} = {4 + 2 Cos[t], 2 Sin[t]} /. \[Phi]r -> wrap;
{X[3], Y[3]} = {8 + 2 Cos[t], 2 Sin[t]} /. \[Phi]r -> wrap;
{X[4], Y[4]} = {4 + 6 Cos[t], 6 Sin[t]} /. \[Phi]r -> wrap;
(* Transformation *)
{abx, aby, abz, dm} = M . {X[1], Y[1], 0, 1};
{bcx, bcy, bcz, dm} = M . {X[2], Y[2], 0, 1};
{cdx, cdy, cdz, dm} = M . {X[3], Y[3], 0, 1};
{dex, dey, dez, dm} = M . {X[4], Y[4], 0, 1};
(* Parametric Plots *)
plot = {
ParametricPlot3D[
{abx, aby, abz} // Evaluate, {t, 0, Pi}, {\[Phi]r, 0, wrap},
MaxRecursion -> 0, PlotPoints -> {400, 400},
MeshFunctions -> {#4 &}, Mesh -> {{0, wrap}},
MeshStyle -> Directive@{Thick, Red}, Boxed -> False,
Axes -> False, Method -> {"BoundaryOffset" -> False}
],
ParametricPlot3D[
{bcx, bcy, bcz} // Evaluate, {t, Pi, 2 Pi}, {\[Phi]r, 0, wrap},
MaxRecursion -> 0, PlotPoints -> {400, 400},
MeshFunctions -> {#4 &}, Mesh -> {{0, wrap}},
MeshStyle -> Directive@{Thick, Red}, Boxed -> False,
Axes -> False, Method -> {"BoundaryOffset" -> False}
],
ParametricPlot3D[
{cdx, cdy, cdz} // Evaluate, {t, 0, Pi}, {\[Phi]r, 0, wrap},
MaxRecursion -> 0, PlotPoints -> {400, 400},
MeshFunctions -> {#4 &}, Mesh -> {{0, wrap}},
MeshStyle -> Directive@{Thick, Red}, Boxed -> False,
Axes -> False, Method -> {"BoundaryOffset" -> False}
],
ParametricPlot3D[
{dex, dey, dez} // Evaluate, {t, Pi, 2 Pi}, {\[Phi]r, 0, wrap},
MaxRecursion -> 0, PlotPoints -> {400, 400},
MeshFunctions -> {#4 &}, Mesh -> {{0, wrap}},
MeshStyle -> Directive@{Thick, Red}, Boxed -> False,
Axes -> False, Method -> {"BoundaryOffset" -> False}
]
};
(* Extract Points and Polygons *)
pts = Cases[plot, GraphicsComplex[pts_, rest__] :> pts, -1][[1]];
polys = Cases[plot, GraphicsGroup[data_] :> data, -1][[1, 1]];
lines = Cases[plot, _Line, -1];
(* Create MeshRegion *)
reg = BoundaryMeshRegion[pts,
Polygon[Join[lines /. Line[pts_] :> Rest@pts, First@First@polys]]]
My Questions:
- How can I address the non-coplanar vertex issue? Is there a reliable way to preprocess the data to ensure coplanarity?
- Does the fact that the
t
ranges differ between parametric equations affect how the points or polygons should be combined? - Should I use an alternative method (e.g.,
MeshRegion
) instead ofBoundaryMeshRegion
? - Is there a way to triangulate the extracted surface data to resolve this issue?
Thank you for your time and insights—any help would be greatly appreciated!
wrap
? please post the full code about the 2D and 3D graphics. $\endgroup$