Message Boards Message Boards

Add Texture to 3D Object?

Posted 4 years ago

It is necessary to build an illustration for the physics idea. 3D object is already constructed:

ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}]

But additional texture does not work:

PlotStyle -> Texture[ExampleData[{"Texture", "Hexagon"}]]]
POSTED BY: Olga Piskounova
4 Replies

That is great, Clayton! It takes me some time to adapt your Texture, thanks. The trick is with the specific number of hexagons to be closed on the torus. OK, it is also understandable, if initial Texture is squared. But would be interesting to extract these discreet numbers from Matematica.

POSTED BY: Olga Piskounova
Posted 4 years ago

Take a look at this MSE answer.

POSTED BY: Rohit Namjoshi

One issue is that "Hexagon" is not a pre-defined texture. You'll need to make your own hexagon image that you want to use as a texture. For example, this code:

hex = With[{t = 0., cols = RGBColor /@ {"#7696DB", "#562D7D"}},
  Graphics[{Thickness[.005], CapForm["Round"], Table[{
      cols[[1]],
      Line[{Sqrt[3] (i + (-1)^j/4), 3/2 j} + # & /@ (Sqrt[3]/
           2 {{Cos[\[Theta]], 
            Sin[\[Theta]]}, {Cos[\[Theta] + 2 \[Pi]/6], 
            Sin[\[Theta] + 2 \[Pi]/6]}})]}, {i, -4, 4}, {j, -4, 
      4}, {\[Theta], (-1)^j \[Pi]/6, 2 \[Pi] - (-1)^j \[Pi]/6, 
      2 \[Pi]/6}]}, 
   PlotRange -> {{-6 + Sqrt[3]/4, 6 + Sqrt[3]/4}, {-6, 6}}, 
   Background -> cols[[-1]], ImageSize -> 540]
  ]

...produces the following image:

Hexagon grid on purple background

Then we can apply this as a texture on your torus (notice, in particular, the use of Mesh -> None, Lighting -> "Neutral", and PlotPoints -> 25 to make this look better):

ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], 
  Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, PlotStyle -> Texture[hex], 
 Mesh -> None, Lighting -> "Neutral", PlotPoints -> 25]

Here's the result:

Hexagons tiling a torus

Try:

$Version
 (*"12.1.0 for Microsoft Windows (64-bit) (March 14, 2020)"*)

ParametricPlot3D[{1.16^v Cos[v] (1 + Cos[u]), -1.16^v Sin[
    v] (1 + Cos[u]), -2 1.16^v (1 + Sin[u])}, {u, 0, 2 Pi}, {v, -15, 
  6}, PlotStyle -> 
  Directive[Specularity[White, 30], 
   Texture[ExampleData[{"ColorTexture", "WhiteMarble"}]]], 
 TextureCoordinateFunction -> ({#4, 2 #5} &), Lighting -> "Neutral", 
 Mesh -> None, PlotRange -> All]

enter image description here

For more see here:

POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract