# Interior of simple closed curve

If we are given a closed curve $$(x(t),y(t))$$, $$0, then how to extract the region inside it ?

I have seen answers that use FilledCurve and BSpline, but I don't want to extract some points and then join them again into an spline. For instance, consider the rhombus

 x[t_] := -(Piecewise[{{-1, Inequality[0, Less, t, LessEqual, 2]},
{-3 + t, Inequality[2, Less, t, LessEqual, 4]},
{1, Inequality[4, Less, t, LessEqual, 6]},
{7 - t, Inequality[6, Less, t, LessEqual, 8]}}, 0]/Sqrt[2]) +
Piecewise[{{-1 + t, Inequality[0, Less, t, LessEqual, 2]},
{1, Inequality[2, Less, t, LessEqual, 4]},
{5 - t, Inequality[4, Less, t, LessEqual, 6]},
{-1, Inequality[6, Less, t, LessEqual, 8]}}, 0]/Sqrt[2]

y[t_] := Piecewise[{{-1, Inequality[0, Less, t, LessEqual, 2]},
{-3 + t, Inequality[2, Less, t, LessEqual, 4]},
{1, Inequality[4, Less, t, LessEqual, 6]},
{7 - t, Inequality[6, Less, t, LessEqual, 8]}}, 0]/Sqrt[2] +
Piecewise[{{-1 + t, Inequality[0, Less, t, LessEqual, 2]},
{1, Inequality[2, Less, t, LessEqual, 4]},
{5 - t, Inequality[4, Less, t, LessEqual, 6]},
{-1, Inequality[6, Less, t, LessEqual, 8]}}, 0]/Sqrt[2]


(nothing special about it, just as an example) then how to get interior as a discretized region ?

• poly = Polygon@Table[{x[t], y[t]}, {t, 1, 8, 1}] ?
– Syed
Dec 26, 2022 at 15:45
• @Syed True. But as I mentioned, it doesn't make too much sense to discretize a continuous closed curve whose analytic expression is known. Dec 26, 2022 at 15:47
• If you don't want any discretization, then I think you're going to need to use the implicit region functionality. We could "regionize" your example with ParametricRegion[{x[t], y[t]}, {{t, 0, 8}}], but that just gets us a 1-D region. To get a 2-D region, I think you're going to need to provide the 2-D parameterization. You could do this by adding a second parameter and filling out the interior with vectors from {0,0} to {x[t],y[t]}. I'm not aware of a built-in function that automatically creates "interior" regions from non-mesh boundary regions in the general case. Dec 26, 2022 at 18:41
• To go the discretization route, you don't need splines. Your function can generate a parametric plot on which you can use DiscretizeGraphics. You can control the refinement of the discretiztion. Then you'll have a boundary made up of 1-D sub-regions. Extract these and create a FilledCurve and discretize the results. That seems like more steps than necessary, so maybe someone else has a more direct route. But the main point is that I don't think there is a built in function that creates interior regions bounded by parameterized functions defining the boundary. Dec 26, 2022 at 18:54
• Oh, sorry, I overlooked your last comment...so you DO want a discretized region. I'll put together an answer... Dec 26, 2022 at 18:58

• Since in the original parametric equation,{x[0],y[0]} is not equal to {x[8],y[8]}, it means that such curve is not a closed curve. We need to replace some Less to LessEqual.
Clear[x,y];
x[t_] = -(Piecewise[{{-1,
Inequality[0, LessEqual, t, LessEqual, 2]}, {-3 + t,
Inequality[2, Less, t, LessEqual, 4]}, {1,
Inequality[4, Less, t, LessEqual, 6]}, {7 - t,
Inequality[6, Less, t, LessEqual, 8]}}, 0]/Sqrt[2]) +
Piecewise[{{-1 + t, Inequality[0, LessEqual, t, LessEqual, 2]}, {1,
Inequality[2, Less, t, LessEqual, 4]}, {5 - t,
Inequality[4, Less, t, LessEqual, 6]}, {-1,
Inequality[6, Less, t, LessEqual, 8]}}, 0]/Sqrt[2];

y[t_] = Piecewise[{{-1,
Inequality[0, LessEqual, t, LessEqual, 2]}, {-3 + t,
Inequality[2, Less, t, LessEqual, 4]}, {1,
Inequality[4, Less, t, LessEqual, 6]}, {7 - t,
Inequality[6, Less, t, LessEqual, 8]}}, 0]/Sqrt[2] +
Piecewise[{{-1 + t, Inequality[0, LessEqual, t, LessEqual, 2]}, {1,
Inequality[2, Less, t, LessEqual, 4]}, {5 - t,
Inequality[4, Less, t, LessEqual, 6]}, {-1,
Inequality[6, Less, t, LessEqual, 8]}}, 0]/Sqrt[2];

{x[0], y[0]} == {x[8], y[8]}


True.

• Now we can directly use BoundaryDiscretizeGraphics by add Exclusions -> None to contain the boundary point of segment to make the curves be a closed curve.
ParametricPlot[{x[t], y[t]}, {t, 0, 8},
Exclusions -> None] // BoundaryDiscretizeGraphics


• Wonderful ! Thank you. Dec 27, 2022 at 1:30
• Nice! I hoped there would be a better way! Dec 27, 2022 at 2:10

This seems a bit cumbersome, I know, but I don't know of a direct route.

boundary = ParametricPlot[{x[t], y[t]}, {t, 0, 8}];
DiscretizeGraphics[FilledCurve[MeshPrimitives[DiscretizeGraphics[boundary], 1]]]