Grafika v 3D

1 Základní volby, ovlivňující vzhled 3D grafiky

(%i1) wxplot3d(cos(x*y),[x,-3,3], [y,-3,3]);

Result

(%i2) wxplot3d(sqrt(1-x^2-y^2),[x,-1,1],[y,-1,1]);

Result

(%i3) f(x,y):=cos(x*y)$

(%i4) plot3d(f(x,y), [x,-3,3], [y,-3,3], ['grid,49,49],[box,false],[legend,false],[plot_format, openmath]);

Result

(%i5) load(draw)$

(%i6) wxdraw3d(surface_hide=true, explicit(f(x,y),x,-3,3,y,-3,3));

Result

(%i7) wxdraw3d(surface_hide=true, enhanced3d=true, explicit(f(x,y),x,-3,3,y,-3,3));

Result

(%i8) wxdraw3d(surface_hide=true, enhanced3d=true, colorbox=false,
explicit(f(x,y),x,-3,3,y,-3,3));

Result

(%i9) wxdraw3d (user_preamble = "set pm3d at s depthorder",
        color = green,
        explicit(f(x,y), x,-3,3,y,-3,3)) $

Result

(%i10) wxdraw3d(zrange=[0,20],
xu_grid=25, yv_grid=25,explicit(1/(x^2+y^2), x,-1,1, y,-1,1));

Result

(%i11) f1(x,y):=(x^2*y)/(x^2+y^2);

Result

(%i12) wxplot3d(f1(x,y), [x,-3,3], [y,-3,3]);

Result

2 Speciální obrázky v 3D

Křivka daná parametricky

(%i13) wxdraw3d(nticks=60, line_width=3, color=blue,
parametric(cos(5*u)^2,sin(7*u),u-2,u,0,2)) $

Result

(%i14) wxdraw3d(nticks=400, line_width=2, color=red,
parametric(t*cos(2*%pi*t), t*sin(2*%pi*t), 2+t,t,0,10))$

Result

(%i15) wxdraw3d(nticks=400, line_width=2, color=red,
parametric(t*cos(2*%pi*t), t*sin(2*%pi*t), 2+t,t,0,10),
parametric(2+t, t*cos(2*%pi*t), t*sin(2*%pi*t),t,0,10),
parametric(t*cos(2*%pi*t), 2+t, t*sin(2*%pi*t),t,0,10))$

Result

Plocha daná parametricky

(%i16) wxdraw3d(xu_grid = 50,
       yv_grid = 15,
       surface_hide = true,
         parametric_surface(cos(a)*(3+b*cos(a/2)),
                            sin(a)*(3+b*cos(a/2)),
                            b*sin(a/2), a,-%pi,%pi,b,-1,1) )$

Result

(%i17) wxdraw3d(xu_grid = 15,
       yv_grid = 45,
       enhanced3d = true,
       surface_hide = true,
         parametric_surface(r*cos(phi), r*sin(phi), phi, r,0,1,phi,0,6*%pi) )$

Result

(%i18) wxdraw3d(surface_hide = true,
color = "midnight-blue",proportional_axes=xyz,
 axis_3d = false,
 xtics = none,
 ytics = none,
 ztics = none,
spherical(1,theta,0,2*%pi,phi,0,%pi))$

Result

(%i19) wxdraw3d(surface_hide = true,proportional_axes=xy,
color = "midnight-blue",
 axis_3d = false,
 xtics = none,
 ytics = none,
 ztics = none,
cylindrical(1/2,z,-2,2,theta,0,2*%pi))$

Result

(%i20) wxdraw3d(surface_hide = true,
color = "blue",proportional_axes=xyz,
 axis_3d = false,
 xtics = none,
 ytics = none,
 ztics = none,
spherical(1,theta,0,2*%pi,phi,0,%pi),
color=red,
cylindrical(1/2,z,-2,2,theta,0,2*%pi))$

Result

(%i21) wxdraw3d(color = blue,
         explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3),
       yv_grid = 10,
       color = red,
         explicit(x+y,x,-5,5,y,-5,5),
       surface_hide = true);

Result

(%i22) f(x,y):=x^2+y^2-4;

Result

(%i23) wxdraw3d(surface_hide = true,
       xlabel = "x",
       ylabel = "y",
       zlabel = "z",
      
       color = coral,
       xu_grid = 20,
       yv_grid = 10,
         explicit(x^2+y^2-4,x,-1.2,1.2,y,-1.2,1.2),
       color = black,
       line_width = 2,
       nticks = 40,
            parametric(cos(t),sin(t),f(cos(t), sin(t)),t,0,2*%pi) );

Result

(%i24) wxdraw3d(surface_hide = true,
       xlabel = "x",
       ylabel = "y",
       zlabel = "z",
      
       color = coral,
       xu_grid = 20,
       yv_grid = 10,
         explicit(x^2+y^2-4,x,-1.2,1.2,y,-1.2,1.2),
       color = black,
       line_width = 3,
       nticks = 40,
            parametric(cos(t),sin(t),(f(cos(t), sin(t))+0.1),t,0,2*%pi) );

Result

(%i25) U:log(sqrt((x+1)^2+y^2)) + log(sqrt((x-1)^2+y^2)) + log(sqrt((y+1)^2+x^2)) + log(sqrt((y-1)^2+x^2))$

(%i26) U;

Result

(%i27) wxdraw3d(xu_grid=50,
       yv_grid=50,
explicit(U,x,-3/2,3/2,y,-3/2,3/2),
       contour_levels = 30,
       contour = map,
       surface_hide = true) ;

Result

(%i28) wxdraw3d(color = green,
         explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
       contour_levels = 15,
       contour = both,
       surface_hide = true) ;

Result

(%i29) wxdraw3d(
  surface_hide = true,
  color = green,
  explicit(exp(-x^2-y^2),x,-2,2,y,-2,2),
  contour = surface,
  contour_levels = 3);

Result

(%i30) wxdraw3d(enhanced3d = true,
       implicit(x^3 + y^3 + z^3 + 1 = (x + y +z+1)^3,x,-2,2,y,-2,2,z,-2,2),
       surface_hide = true)$

Result

3 Animace

(%i31) for d:1 thru 2 step 0.1 do
  plot2d(sin(x*d),[x,-10,10]);

Result

(%i32) with_slider(
d,makelist(i,i,10,20)/10,
[sin(x*d)],[x,-10,10],[y,-1,1]);

Result

(%i33) for d:1 thru 2 step 0.1 do
  draw2d(explicit(sin(x*d),x,-10,10));

Result

(%i34) with_slider_draw(
d,makelist(i,i,10,20)/10,
explicit(sin(d*x),x,-10,10)
);

Result

(%i35) for d:1 thru 2 step 0.1 do
  draw3d(enhanced3d = true,explicit(cos(x*d)*sin(y*d),x,-%pi,%pi,y,-%pi,%pi));

Result

Vytvoření animovaného gifu na Linuxu

Vytvoří jednotlivé PNG soubory

(%i36) for k:1 thru 10 do
  draw2d(terminal = png,
         file_name = concat("ga",add_zeroes(k)),
         pic_width = 300,
         pic_height = 300,
         explicit(x^(0.1*k),x,0,1));

Result

Pomocí systémové příkazu convert je pak spojíme dohromady a vytvoříme animovaný gif.

(%i37) system("convert -delay 10 ga*.png gifanim.gif")$

4 Geometrické obrazce

--> wxdraw2d(fill_color = "sea-green",
       color = aquamarine,
       line_width = 6,
           polygon([[1,1],[3,0],[4,5],[0,3]]),

       transparent = true,
       line_type = dots,
       color = "dark-yellow",
           polygon([4,5,7],[6,4,2]),

       line_type = solid,
       transparent = false,
       fill_color = violet,
           rectangle([-2,-2],[8,-1]), /* protilehle vrcholy */

       transparent = true,
       color = "dark-goldenrod",
       line_width = 1,
           rectangle([9,4],[2,-1.5]),

       transparent = false,
       fill_color = grey80,
       line_width = 2,
           ellipse(0,6,3,2,270,-270),

       transparent = true,
       color = "NaVy",
       line_width = 3,
           ellipse(7,6,2,3,30,-90),

       xrange = [-3,10],
       yrange = [-3,9] )$

Result


Created with wxMaxima.