# How to remove parts of a curve?

I have a curve that have some unwanted parts. How can I remove them ? Or how to constraint the curve to a specific region ?

Here's a MWE that shows the problem :

t[tau_, v_, g_] := (Sinh[g tau + ArcTanh[v]] - Sinh[ArcTanh[v]])/g
x[tau_, v_, g_] := (Cosh[g tau + ArcTanh[v]] - Cosh[ArcTanh[v]])/g

Chi[t_, x_] := ArcTan[t + x] - ArcTan[t - x]
Eta[t_, x_] := ArcTan[t + x] + ArcTan[t - x]

curve[v_, g_] := ParametricPlot[
{Chi[t[tau, v, g], x[tau, v, g]], Eta[t[tau, v, g], x[tau, v, g]]},
{tau, -50, 50},
PlotRange -> All
]

Show[curve[0.5, 2],
PlotRange -> {{-Pi, Pi}, {-Pi, Pi}},
Frame -> True]


Preview : The interesting part of that curve is inside the region delimited by a simple square losange, with corners at {-Pi, 0}, {0, -Pi}, {Pi, 0}and {0, Pi}.

So how can we draw the parts contained in that region only ?

• Maybe do instead {tau, -3, 3}. – march Apr 22 '16 at 15:54
• Use in your curve function {tau, -10, 9.5} instead of {tau, -50, 50}. – demm Apr 22 '16 at 15:56
• Well, this would be specific to the values used for v and g, wouldn't ? I need something more general, for all values of those parameters. – Cham Apr 22 '16 at 16:01

curve[v_, g_] := ParametricPlot[{Chi[t[tau, v, g], x[tau, v, g]],
Eta[t[tau, v, g], x[tau, v, g]]}, {tau, -50, 50}, PlotRange -> All,
RegionFunction -> Function[{x, y, u}, Norm[{x, y}, 1] < .99999 Pi]]

Show[RegionPlot[Norm[{x, y}, 1] <= Pi, {x, -Pi, Pi}, {y, -Pi, Pi}],
curve[0.5, 2], PlotRange -> {{-Pi, Pi}, {-Pi, Pi}}, Frame -> True] Show[RegionPlot[Norm[{x, y}, 1] <= Pi, {x, -Pi, Pi}, {y, -Pi, Pi}],
curve[.5, -4], PlotRange -> {{-Pi, Pi}, {-Pi, Pi}}, Frame -> True] • Wow ! That solution works very well. Please, could you explain what the Function[{x, y, u}, Norm[{x, y}, 1] < .99999 Pi] is doing ? – Cham Apr 22 '16 at 23:03
• @Cham, Your diamond is the region where 1-norm is equal to Pi, i.e., the region where Norm[{x,y},1] ==Pi. So, the specified RegionFunction is restricting the plotting region to {x,y} values with 1-norm less than Pi. – kglr Apr 22 '16 at 23:12
• I'm not sure to understand. What is a 1-norm ? Norm[{x, y}] = Sqrt[x^2 + y^2], isn't ? Then what is Norm[{x, y}, 1] ? – Cham Apr 22 '16 at 23:14
• Also, what is the u variable, in your {x, y, u} ? – Cham Apr 22 '16 at 23:18
• @Cham, Sqrt[x^2 + y^2] is the 2-Norm. 1-Norm is Norm[{x, y}, 1] =Abs[x] + Abs[y] (see Norm>>Neat Examples.) The u the RegionFunction arguments corresponds to the u in ParametricPlot[{fx, fy}, {u, umin, umax}] , that is, it corresponds to tau in your curve function. – kglr Apr 22 '16 at 23:33

Using your definitions, let's derive a RegionMemberFunction that indicates whether a point lies on the boundary of the diamond-shaped region that you want to exclude from plotting:

rmf = RegionMember@DiscretizeRegion@Line[{{-Pi, 0}, {0, -Pi}, {Pi, 0}, {0, Pi}, {-Pi, 0}}];


Notice that the first point must be repeated to obtain a closed line.

Using that region membership function, we can define a new parametric plot including a RegionFunction directive that tests points to plot, and only plots them if they are not on part of that boundary:

Clear[curveLimited]
curveLimited[v_, g_] :=
ParametricPlot[{Chi[t[tau, v, g], x[tau, v, g]],
Eta[t[tau, v, g], x[tau, v, g]]}, {tau, -50, 50}, PlotRange -> All,
RegionFunction -> (Not[rmf[{#1, #2}]] &)
]

Show[
curveLimited[.5, 2],
PlotRange -> {{-Pi, Pi}, {-Pi, Pi}}, Frame -> True
] This works automatically for any value of the plotting parameters:

Show[
curveLimited[.999, -3],
PlotRange -> {{-Pi, Pi}, {-Pi, Pi}}, Frame -> True
] 