6
$\begingroup$

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] } ]
$\endgroup$
4
  • 1
    $\begingroup$ You might want to look into RegionFunction... $\endgroup$ Jul 27, 2012 at 13:37
  • $\begingroup$ @ThiagoMarihno What exactly is plotted incorrectly ? $\endgroup$
    – Artes
    Jul 27, 2012 at 14:07
  • $\begingroup$ 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. $\endgroup$ Jul 27, 2012 at 14:22
  • $\begingroup$ Simon, That's exactly the problem i'm having, thanks for the reply. $\endgroup$ Jul 27, 2012 at 15:20

2 Answers 2

6
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ uu is a good idea, +1 $\endgroup$
    – Artes
    Jul 31, 2012 at 0:26
  • $\begingroup$ @Heike, elegant solution. Thanks $\endgroup$ Aug 2, 2012 at 12:44
5
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ Thanks, Very helpfull. Will try it out now! $\endgroup$ Jul 27, 2012 at 15:19
  • $\begingroup$ 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. $\endgroup$ Jul 27, 2012 at 17:42
  • $\begingroup$ @ThiagoMarinho If you increse PlotPoints and/or MaxRecursion there shouldn't be any holes. Try Mesh -> None to get rid of unwanted mesh. $\endgroup$
    – Artes
    Jul 27, 2012 at 19:06
  • $\begingroup$ Have you tried PlotPoints -> 300, MaxRecursion -> 6 ? In this case it yields a plot with no holes. $\endgroup$
    – Artes
    Jul 27, 2012 at 19:32
  • $\begingroup$ 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. $\endgroup$ Aug 2, 2012 at 12:32

Your Answer

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

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