6
$\begingroup$

I need to put some simple textures to some parametric plots. My textures are not complicated, They are like the first example in here. Is there any simple way of doing this?

For example, How can I put this texture:

enter image description here

on this parametric surface:

f = {u, Sin[v]*(u^3 + 2 u^2 - 2 u + 2)/5, 
   Cos[v]*(u^3 + 2 u^2 - 2 u + 2)/5};

uRange = {u, -2.3, 1.3}
vRange = {v, 0, 2 Pi}

enter image description here

Note that I'm not looking for the best way of doing this, and the best possible output quality, I'm just looking for something simple and easy to understand.

$\endgroup$
3
  • 1
    $\begingroup$ What have you tried so far? The page you link to had an example with ParametricPlot3D. Why didn't the same method shown there work for you? People will be reluctant to give yet another example seeing that you have already ignored one in the documentation and didn't explain the difficulty with it. $\endgroup$
    – Szabolcs
    Commented Dec 7, 2014 at 18:40
  • 1
    $\begingroup$ The docs for Texture[] contains at least one example of the usage with ParametricPlot3D[]. If you already saw it, please specify how your requirements differ from it. $\endgroup$ Commented Dec 7, 2014 at 18:45
  • $\begingroup$ @Szabolcs Yes you are right, I should have explained my problem. The first problem is that I didnt know how to import textures. But now that kguler answered my question, I think I know what to do. $\endgroup$
    – lino
    Commented Dec 7, 2014 at 18:46

1 Answer 1

15
$\begingroup$
image = Import["https://i.sstatic.net/6YRfK.jpg"];

If you want to use your f, uRange and vRange as the arguments to ParamatricPlot3D, you need to wrap each with Evaluate:

f = {u, Sin[v]*(u^3 + 2 u^2 - 2 u + 2)/5,  Cos[v]*(u^3 + 2 u^2 - 2 u + 2)/5};
uRange = {u, -2.3, 1.3};
vRange = {v, 0, 2 Pi};

ParametricPlot3D[Evaluate@f, Evaluate@uRange, Evaluate@vRange, 
 Mesh -> None, PlotStyle -> Texture[image], Lighting -> "Neutral"]

enter image description here

Alternatively, you can set the option TextureCoordinateScaling to False

ParametricPlot3D[Evaluate@f, Evaluate@uRange, Evaluate@vRange, Mesh -> None, 
  PlotStyle -> Texture[image], Lighting -> "Neutral", TextureCoordinateScaling -> False]

to get

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ PlotStyle can apply to points, lines and surfaces. I like it! +1 $\endgroup$
    – user9660
    Commented Dec 7, 2014 at 18:48
  • $\begingroup$ @Lou, thank you for the upvote. $\endgroup$
    – kglr
    Commented Dec 7, 2014 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.