# "Filled in" ParametricPlot3D?

**URL:** <https://community.wolfram.com/t/filled-in-parametricplot3d/11570>\
**Category:** Questions\
**Tags:** geometry, graphics-and-visualization\
**Created:** [November 23, 2017, 8:55pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570 "2017-11-23T20:55:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidjlynch20](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@davidjlynch20](https://community.wolfram.com/u/davidjlynch20)\
**Post date:** [November 23, 2017, 8:55pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/1 "2017-11-23T20:55:37Z")

</div>

Hello all! I’m currently finding my way through Mathematica (novice here), and am having issues “filling in” a Parametric3DPlot, as shown below:

```
ParametricPlot3D[{(1 + Cos[(8 t)]) Cos[t], (1 + Cos[8 t]) Sin[t], u}, 
{t, 0, 2 Pi}, {u, 0, 1}, Mesh -> None, PlotStyle -> Opacity[.9]]

```

While these “petals” somewhat work, how do I fill them in, to make them a solid shape? Thanks!

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [November 24, 2017, 7:12am UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/2 "2017-11-24T07:12:21Z")

</div>

Here is a way:

```
f[t_, u_, r_] = {r (1 + Cos[(8 t)]) Cos[t], r (1 + Cos[8 t]) Sin[t], 
   u};
Show[ParametricPlot3D[f[t, u, 1], {t, 0, 2 Pi}, {u, 0, 1}, 
  Mesh -> None, PlotStyle -> Opacity[.9], PlotPoints -> {40, 2}],
 ParametricPlot3D[{f[t, 1, r], f[t, -1, r]}, {t, 0, 2 Pi}, {r, 0, 1}, 
  Mesh -> None, PlotStyle -> Opacity[.9], PlotPoints -> {40, 2}]]

```

---

<div class="post-metadata">

**Author:** ![mroge02](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mroge02/32/28775_2.png) [@mroge02](https://community.wolfram.com/u/mroge02)\
**Post date:** [November 24, 2017, 3:47pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/3 "2017-11-24T15:47:07Z")

</div>

The following uses the vertices of the top and bottom edges, where `u` is approximately one of `{0, 1}`. It is only approximate because `ParametricPlot3D` uses open sampling. The advantage to using the actually discrete edges of the graphics is that the lids “fit tightly.”

```
ParametricPlot3D[{(1 + Cos[(8 t)]) Cos[t], (1 + Cos[8 t]) Sin[t], u},
  {t, 0, 2 Pi}, {u, 0, 1},
  PlotPoints -> {120, 5},
  Mesh -> None, PlotStyle -> Opacity[0.9], 
  BoundaryStyle -> Opacity[0.9]] /.     
 GraphicsComplex[pts_, g_, opts_] :>
  GraphicsComplex[
   pts, (* array of coordinates of points in the graphics *)
   g /. Line[idcs_] :> { (* points are specified by their indices in the coordinate array pts *)
      EdgeForm[],
      Polygon[
       SplitBy[
        Select[
         idcs,
         Min@Abs[pts[[#, 3]] - {0, 1}] < 1*^-6 &], (* select indices at the boundary edges {0, 1} *)
        Nearest[{0, 1}, pts[[#, 3]]] &], (* split the indices according to bottom, top {0, 1} *)
       VertexNormals -> None] (* the polygons are virtually flat and should not inherit the VertexNormals
                                     assigned to their points on the original surface (the sides) *)
      },
   opts]

```

Alternatively, one can construct a cylinder given a base polygon.

```
base = First@Cases[
    ParametricPlot[{(1 + Cos[(8 t)]) Cos[t], (1 + Cos[8 t]) Sin[t]}, {t, 0, 2 Pi}],
    Line[p_] :> p, Infinity];
RegionProduct[Polygon[base], Line[{{0.}, {1.}}]]

```

Or just construct the base directly with `Table`:

```
base = Most@
   Table[{(1 + Cos[(8 t)]) Cos[t], (1 + Cos[8 t]) Sin[t]},
    {t, 0., 2 Pi, 2 Pi/8/100}]; (* 100 yields a sufficient sampling density *)

```

---

<div class="post-metadata">

**Author:** ![davidjlynch20](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@davidjlynch20](https://community.wolfram.com/u/davidjlynch20)\
**Post date:** [November 24, 2017, 6:13pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/4 "2017-11-24T18:13:10Z")

</div>

This is so helpful, thank you all. One more question: I am trying to combine this with another ParametricPlot3D, but whenever I try the command Show[{figure1,figure2,figure3}, PlotRange-\>All], it returns that it cannot combine them. Any help with this part?

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [November 24, 2017, 6:29pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/5 "2017-11-24T18:29:54Z")

</div>

You can also use the derived geometric region functions:

```
RegionProduct[
 BoundaryDiscretizeGraphics@
  ParametricPlot[{(1 + Cos[(8 t)]) Cos[t], (1 + Cos[8 t]) Sin[t]},
   {t, Pi/8, 2 Pi + Pi/8}],
 DiscretizeRegion@Line[{{0}, {1}}]]

```

---

<div class="post-metadata">

**Author:** ![davidjlynch20](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@davidjlynch20](https://community.wolfram.com/u/davidjlynch20)\
**Post date:** [November 24, 2017, 8:07pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/6 "2017-11-24T20:07:02Z")

</div>

[@Gianluca Gorni](http://community.wolfram.com/web/gianlucagorni) thank you so much! One last question (sorry!): how do I change the color of this graphic? I’m confused as to where I would put it in the coding. 🙂

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [November 24, 2017, 8:28pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/7 "2017-11-24T20:28:29Z")

</div>

Right now I cannot check with Mathematica, but you may look up `MeshPrimitives`, that converts a Region to `Graphics3D`, to which you can give color styling.

---

<div class="post-metadata">

**Author:** ![davidjlynch20](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@davidjlynch20](https://community.wolfram.com/u/davidjlynch20)\
**Post date:** [November 24, 2017, 9:00pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/8 "2017-11-24T21:00:03Z")

</div>

[@Gianluca Gorni](http://community.wolfram.com/web/gianlucagorni) Hm… can’t seem to exactly find the right resources to convert the code you gave me into a MeshFunction. Perhaps when you get the chance you could help me. Thanks!

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [November 25, 2017, 3:00pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/9 "2017-11-25T15:00:12Z")

</div>

Here is an example:

```
reg = RegionProduct[
   BoundaryDiscretizeGraphics@
    ParametricPlot[{(1 + Cos[(8 t)]) Cos[t], (1 + Cos[8 t]) Sin[
        t]}, {t, Pi/8, 2 Pi + Pi/8}],
   DiscretizeRegion@Line[{{0}, {1}}]];
Graphics3D[{Red, EdgeForm[], MeshPrimitives[reg, 2]}]

```

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [November 26, 2017, 9:08pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/10 "2017-11-26T21:08:43Z")

</div>

This is a ligher version, with only the boundary shown:

```
reg = RegionBoundary@
   RegionProduct[
    BoundaryDiscretizeGraphics@
     ParametricPlot[{(1 + Cos[(8 t)]) Cos[t], (1 + Cos[8 t]) Sin[
         t]}, {t, Pi/8, 2 Pi + Pi/8}], 
    DiscretizeRegion@Line[{{0}, {1}}]];
Graphics3D[{Red, EdgeForm[], Opacity[.5], MeshPrimitives[reg, 2]}]

```

---

<div class="post-metadata">

**Author:** ![anon21378091](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon21378091](https://community.wolfram.com/u/anon21378091)\
**Post date:** [November 27, 2017, 2:16pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/11 "2017-11-27T14:16:24Z")

</div>

Very interesting solutions! Michael, thanks, but where do you get and what is the meaning of:

```
Line[{{0}, {1}}] ?

```

I cannot find in the Line docs any such syntax for Line[].

Also,

```
Graphics[Line[{{0}, {1}}]]

```

gives the error: "Array {{0}, {1}} has the wrong dimensions for a graphics coordinate list. Am I missing something?

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [November 27, 2017, 3:40pm UTC](https://community.wolfram.com/t/filled-in-parametricplot3d/11570/12 "2017-11-27T15:40:19Z")

</div>

The special syntax `Line[{{0}, {1}}]` is not used for 2D graphics, but for geometric regions. It means the line in 1D space, connecting the two zero-dimensional points `{0}` and `{1}`.
