Excluding a Region in ParametricPlot3D

Suppose I have a torus and a closed path on said torus:

r = 1;
R = 2.5*r;
a = .8;
b = .4;
path = ParametricPlot3D[{{(R + r Cos[a Sin@w]) Cos[b Cos@w], (R + r Cos[a Sin@w]) Sin[b Cos@w], r Sin[a Sin@w]}}, {w, 0, 2 π},  PlotStyle -> {Black, Thickness[0.008]}];
patch = ParametricPlot3D[{{(R + r Cos@v) Cos@u, (R + r Cos@v) Sin@u, r Sin@v}}, {u, 0, 2 π}, {v, 0, 2 π}, Mesh -> False, PlotStyle -> Opacity[0.75]];
Show[patch, path, Boxed -> False, BoxRatios -> Automatic]


What I want to know is: Is there some way of plotting my torus without the part that is cut out by the path? I'm sure there is an easy way to do this with something like "Eliminate" but it seems just outside of my skill.

• Thanks for the different Ideas. I like the Nearest mixed with RegionFunction as that allows for non-planar paths. – amcalde Sep 9 '14 at 16:48

I tried to generalize for (almost) any reasonable closed path without using the fact that your current path is contained in a known plane.

r = 1;
R = 2.5*r;
a = .8;
b = .4;

torusF[R_, r_, u_, v_] := {(R + r Cos@v) Cos@u, (R + r Cos@v) Sin@u, r Sin@v}
pathF[R_, r_, aa_, bb_, w_] := torusF[R, r, u, v] /. {u -> bb Cos@w, v -> aa Sin@w}

t = Table[pathF[R, r, aa, Rescale[aa, {0,a}, {0,b}], w], {aa, 0, a, a/100}, {w, 0, 2 Pi, 2 Pi/200}];
f = Nearest[Flatten[t, 1]];

path =  ParametricPlot3D[pathF[R, r, a, b, w], {w, 0, 2 Pi}, PlotStyle -> {Black, Thickness[0.008]}];
torus = ParametricPlot3D[ torusF[R, r, u, v], {u, 0, 2 Pi}, {v, 0, 2 Pi},
Mesh -> False, PlotStyle -> Opacity[0.75],
RegionFunction -> Function[{x, y, z}, Norm[f[{x, y, z}, 1][[1]] - {x, y, z}] > .03]];

Show[torus, path, Boxed -> False, BoxRatios -> Automatic]


More complicated paths may require taking more points for the Nearest function:

With:

pathF[R_, r_, aa_, bb_, w_] := torusF[R, r, u, v] /. {u -> bb (Cos@w + .2 Cos[6 w]),
v -> aa (Sin@w + .2 Sin[6 w])}


You get:

With V10 you could use ClipPlanes to get a similar effect

patch =
ParametricPlot3D[{{(R + r Cos@v) Cos@u,(R + r Cos@v) Sin@u,r Sin@v}},
{u, 0, 2 \[Pi]},{v, 0, 2 \[Pi]},
Mesh -> True,
PlotPoints -> 50,
PlotStyle -> Opacity[0.75]];

Show[patch,
ClipPlanes -> {{-3, 0, 0, 10}},
ClipPlanesStyle -> {Directive[Opacity[0.2], Green]},
ImageSize -> 600,
ViewPoint -> {3, -2, 1.5}]


Here is a simple way. It's based on the observation that the path is nearly planar and parallel to the yz-plane. Therefore, the opening can be approximated by not drawing any part of the torus where x exceeds a certain value which can be estimated from the expression given for the path.

r = 1;
R = 2.5*r;
a = .9;
b = .5;
xMax = Min @
Table[{(R + r Cos[a Sin @ w]) Cos[b Cos @ w],
(R + r Cos[a Sin @ w]) Sin[b Cos @ w],
r Sin[a Sin @ w]},
{w, 0, 2 π, .1}][[All, 1]];

path =
ParametricPlot3D[{(R + r Cos[a Sin @ w]) Cos[b Cos @ w],
(R + r Cos[a Sin @ w]) Sin[b Cos @ w],
r Sin[a Sin @ w]},
{w, 0, 2 π},
PlotStyle -> {Black, Thickness[0.008]}];

torus =
ParametricPlot3D[{(R + r Cos @ v) Cos @ u,
(R + r Cos@v) Sin @ u,
r Sin @ v},
{u, 0, 2 π}, {v, 0, 2 π},
Mesh -> False,
RegionFunction -> (#1 < xMax &)];

Show[torus, path, Boxed -> False, BoxRatios -> Automatic]


Is this approximation good for all values of a and b that might be of interest? I don't know for sure, but for the several values that I experimented with, the graphics output looked good.