Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there any way to plot correctly using the ParametricPlot3D command with one of variable's boundaries defined in function of the other ?

In the example given here the variables are u and r.

  • r boundaries are set from 0.01 to d/2
  • u boundaries are set from the lower limit function x0(r) and upper limit function corda(r)-x0(r)

I noticed a problem on the leading edge of this wing profile present only when using a variable boundary, while if I use a constant boundary limit the wing is plotted correctly.

Any ideas on how to solve this problem? The code is presented below for reference.

c = 1;  e = 2;  d = 0.35;
(*Distribuição de Corda*)
corda[r_, c_] := c ( -30.04*r^3 + 4.65*r^2 + 0.116*r + 0.01)
(*Distribuição de Espessura*)
naca[r_, e_] := e ( -47.511*r^3 + 13.346*r^2 - 1.3953*r + 0.1511)
x0[r_, c_] := 0.4 corda[r, c]
(*Imagem do Perfil*)
FNaca[u_, r_, c_, e_] :=
    (naca[r, e]/0.2) corda[r,c] (  0.2969 Sqrt[(u + x0[r, c])/corda[r, c]] 
                                 - 0.126 (u + x0[r, c])/corda[r, c]
                                 - 0.3516 ((u + x0[r, c])/corda[r, c])^2
                                 + 0.2843 ((u + x0[r, c])/corda[r, c])^3 
                                 - 0.1015 ((u + x0[r, c])/corda[r, c])^4 )
m = 0.04;  p = 0.4;
(*Camber Bordo de Ataque*)
ba[u_, r_, c_] := m (u + x0[r, c]) ( 2 p - (u + x0[r, c])/corda[r, c])/p^2 
(*Camber Bordo de Fuga*)
bf[u_, r_, c_] :=
    m ((corda[r, c] - (u + x0[r, c]))/(1 - p)^2) ( 1 + (u + x0[r, c])/corda[r, c] - 2 p)
PerfilSup[u_, r_, c_, e_] := If[ u + x0[r, c] <= p corda[r, c],
                                 FNaca[u, r, c, e] + ba[u, r, c],
                                 FNaca[u, r, c, e] + bf[u, r, c] ]
PerfilInf[u_, r_, c_, e_] := If[ u + x0[r, c] <= p corda[r, c],
                                -FNaca[u, r, c, e] + ba[u, r, c],
                                -FNaca[u, r, c, e] + bf[u, r, c]]
d1[u_, r_, c_, e_] := PerfilInf[u, r, c, e]
f1[u_, r_, c_, e_] := PerfilSup[u, r, c, e]

ParametricPlot3D[{ {d1[u, r, c, e], u, r}, {f1[u, r, c, e], u, r}},
                   {r, 0.01, d/2}, {u, -x0[r, c], corda[r, c] - x0[r, c] } ]
share|improve this question
1  
You might want to look into RegionFunction... –  J. M. Jul 27 '12 at 13:37
    
@ThiagoMarihno What exactly is plotted incorrectly ? –  Artes Jul 27 '12 at 14:07
    
Zooming in, the top and bottom surfaces don't join up very well, but I think that's just a sampling issue. Try setting the option PlotPoints->100. If that's not the problem, you will need to provide more detail in the question. –  Simon Woods Jul 27 '12 at 14:22
    
Simon, That's exactly the problem i'm having, thanks for the reply. –  Thiago Marinho Jul 27 '12 at 15:20
add comment

2 Answers

up vote 6 down vote accepted

For this particular problem you could consider expressing everything in terms of uu == (u + x0[r, c])/corda[r, c] instead of u. The code then becomes something like

c = 1;  e = 2;  d = 0.35;
corda[r_, c_] := c ( -30.04*r^3 + 4.65*r^2 + 0.116*r + 0.01)
naca[r_, e_] := e ( -47.511*r^3 + 13.346*r^2 - 1.3953*r + 0.1511)
x0[r_, c_] := 0.4 corda[r, c]
m = 0.04;  p = 0.4;

FNaca1[uu_, r_, c_, e_] := ((naca[r, e]/0.2) corda[r, c] 
   (0.2969 Sqrt[uu] - 0.126 uu - 0.3516 uu^2 + 0.2843 uu^3 - 0.1015 uu^4))
ba1[uu_, r_, c_] := m corda[r, c] uu (2 p - uu)/p^2    
bf1[uu_, r_, c_] := m corda[r, c] (1 - uu)/(1 - p)^2 (1 + uu - 2 p)
PerfilSup1[uu_, r_, c_, e_] := If[uu <= p , FNaca1[uu, r, c, e] + ba1[uu, r, c], 
   FNaca1[uu, r, c, e] + bf1[uu, r, c]]
PerfilInf1[uu_, r_, c_, e_] := If[uu <= p, -FNaca1[uu, r, c, e] + 
   ba1[uu, r, c], -FNaca1[uu, r, c, e] + bf1[uu, r, c]]
d11[uu_, r_, c_, e_] := PerfilInf1[uu, r, c, e]
f11[uu_, r_, c_, e_] := PerfilSup1[uu, r, c, e]

ParametricPlot3D[{{d11[uu, r, c, e], uu corda[r, c] - x0[r, c], r},
   {f11[uu, r, c, e], uu corda[r, c] - x0[r, c], r}}, 
  {r, 0.01, d/2}, {uu, 0, 1},
  PlotPoints -> 30, MaxRecursion -> 3, BoxRatios -> {1, 3, 6}]

Mathematica graphics

share|improve this answer
    
uu is a good idea, +1 –  Artes Jul 31 '12 at 0:26
    
@Heike, elegant solution. Thanks –  Thiago Marinho Aug 2 '12 at 12:44
add comment

From documentation of ParametricPlot3D :

You should realize that with the finite number of sample points used, it is possible for ParametricPlot3D to miss features in your functions. To check your results, you should try increasing the settings for PlotPoints and MaxRecursion.

and

The default setting PlotPoints->Automatic corresponds to PlotPoints->75 for curves and PlotPoints->{15,15} for surfaces.

First, let's try to decrease the default number of PlotPoints, e.g. :

ParametricPlot3D[{{d1[u, r, c, e], u, r}, {f1[u, r, c, e], u, r}},
                  {r, 0.01, d/2}, {u, -x0[r, c], corda[r, c] - x0[r, c]}, 
                  PlotPoints -> {7, 7}, MaxRecursion -> 1, BoxRatios -> {1.1, 3, 6}]

enter image description here

This plot is even worse than it would have been if PlotPoints option hadn't been specified :

ParametricPlot3D[{{d1[u, r, c, e], u, r}, {f1[u, r, c, e], u, r}}, 
                  {r, 0.01, d/2}, {u, -x0[r, c], corda[r, c] - x0[r, c]}, 
                  BoxRatios -> {1.1, 3, 6}]

enter image description here

Choosing appropriately increased parameters of the options we can get plots of desired quality. However with increased PlotPoints and MaxRecursion timings of rendering plots increase too, it may take even a few minutes.

ParametricPlot3D[{{d1[u, r, c, e], u, r}, {f1[u, r, c, e], u, r}},
                  {r, 0.01, d/2}, {u, -x0[r, c], corda[r, c] - x0[r, c]}, 
                  PlotPoints -> {300, 300}, MaxRecursion -> 6, BoxRatios -> {1, 3, 6}]

enter image description here

Trying another options to customize your plots, these guides would be interesting : 3D Graphics Options and Graphics Options & Styling.

share|improve this answer
    
Thanks, Very helpfull. Will try it out now! –  Thiago Marinho Jul 27 '12 at 15:19
    
That indeed helped a lot, at first it was visually fine, but there are still some very small holes if you zoom in enough. The surface resolution was a lot better aswell but still not nearly as good and precise as a nurbs surface. Im considering making a .txt bot file to draw it on rhinoceros from a few discrete points. Is there anyway to adjust a NURBS surface to these points on mathematica? All the plot commands seem to create meshes. –  Thiago Marinho Jul 27 '12 at 17:42
    
@ThiagoMarinho If you increse PlotPoints and/or MaxRecursion there shouldn't be any holes. Try Mesh -> None to get rid of unwanted mesh. –  Artes Jul 27 '12 at 19:06
    
Have you tried PlotPoints -> 300, MaxRecursion -> 6 ? In this case it yields a plot with no holes. –  Artes Jul 27 '12 at 19:32
    
I've exported the plot to 3ds format and opened the mesh on rhinoceros, you can alway find the holes if you zoom in enough. With higher values on the points option i get a higher definition mesh. Im looking into alternatives to draw this profile correctly for numerical flow applications. –  Thiago Marinho Aug 2 '12 at 12:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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