4.    3D grafika - standardni paketi

4.1.  paket ContourPlot3D

4.1.1. ContourPlot3D

<< Graphics`ContourPlot3D`

ContourPlot3D[
      x^2 + y^2 + z^2 - 1, 
{x, -1, 1}, {y, -1, 
        1}, {z, -1, 1}]

ContourPlot3D[
      x^2 + y^2 + z^2 - 1, {x, -1, 1}, {y, -0.5, 1}, {z, -1, 
        1}, 
PlotPoints -> 
        5, 
Axes -> True, 
      AxesLabel -> {x, y, z}]

ContourPlot3D[
      x^2 + y^2 + z^2 - 1, {x, -1, 1}, {y, -0.5, 1}, {z, -1, 
        1}, 
PlotPoints -> {6, 3, 
          4}, 
Axes -> True, 
      AxesLabel -> {x, y, z}]

ContourPlot3D[
      x^2 + y^2 + z^2, {x, -1, 1}, {y, -0.5, 1}, {z, -1, 
        1}, 
Contours -> {1}, 
Axes -> True, AxesLabel -> {x, y, z}]

ContourPlot3D[
      x^2 + y^2 + z^2, {x, -3, 3}, {y, -0.5, 3}, {z, -3, 
        3}, 
Contours -> {1, 4, 
          9}, 
Axes -> True, 
      AxesLabel -> {x, y, z}]

ContourPlot3D[
      x^2 + y^2 + z^2, {x, -3, 3}, {y, -0.5, 3}, {z, -3, 
        3}, 
Contours -> {1, 4, 
          9}, 
ContourStyle -> {{Hue[1]}, {Hue[
              0.6]}, {Hue[0.2]}}, 
Axes -> True, 
      AxesLabel -> {x, y, z}, 
Lighting -> 
        False]

ContourPlot3D[
      x^2 + y^2 + z^2, {x, -3, 3}, {y, -0.5, 3}, {z, -3, 
        3}, 
Contours -> {1, 4, 
          9}, 
ContourStyle -> {{SurfaceColor[
              Hue[1]]}, {SurfaceColor[Hue[0.6]]}, {SurfaceColor[
              Hue[0.2]]}}, 
Axes -> True, 
      AxesLabel -> {x, y, z}]

ContourPlot3D[
      x^2 + y^2 + z^2, {x, -3, 3}, {y, -0.5, 3}, {z, -3, 
        3}, 
Contours -> {1, 4, 
          9}, 
ContourStyle -> {{FaceForm[
              SurfaceColor[Hue[0.2]], SurfaceColor[Hue[1]]]}, {FaceForm[
              SurfaceColor[Hue[0.3]], SurfaceColor[Hue[0.7]]]}, {FaceForm[
              SurfaceColor[Hue[0.1]], 
              SurfaceColor[Hue[0.6]]]}}, 
Axes -> 
        True, AxesLabel -> {x, y, z}]

ContourPlot3D[
      x^2*y^2 + x^2*z^2 + y^2*z^2 - 1, {x, -2, 2}, {y, -2, 
        2}, {z, -2, 2}, 
      PlotPoints -> 
        5, 
ContourStyle -> {{SurfaceColor[
              RGBColor[1, 0.7, 0]]}}, 
Boxed -> 
        False]

ContourPlot3D[
      x^2*y^2 + x^2*z^2 + y^2*z^2 - 1, {x, -2, 2}, {y, -2, 
        2}, {z, -2, 2}, 
      PlotPoints -> 
        5, 
ContourStyle -> {{GrayLevel[
              1]}}, 
Boxed -> 
        False, 
Lighting -> 
        False, 
Background -> GrayLevel[0.6]]

4.1.2. ListContourPlot3D

ploha= Table[x^2*y^2+x^2*z^2+y^2*z^2-1,
                   {z,-2,2,.25},
                   {y,-2,2,.25},
                   {x,-2,2,.25}];

ListContourPlot3D[ploha, 
      MeshRange -> {{-2, 2}, {-2, 2}, {-2, 2}}]

Clear[ploha]

4.2. paket ParametricPlot3D

4.2.1. Odredivanje koraka varijable

<< Graphics`ParametricPlot3D`

helikoid[a_, b_][u_, v_] := {a*v*Cos[u], a*v*Sin[u], 
        b*u}

ParametricPlot3D[helikoid[2, 1/2][u, v] // Evaluate, {u, Pi, 
        15  Pi/2}, {v, 0, 3}, ViewPoint -> {1, 2, 1}]

ParametricPlot3D[helikoid[2, 1/2][u, v] // Evaluate, {u, Pi, 
        15  Pi/2, Pi/24}, {v, 0, 3}, ViewPoint -> {1, 2, 1}]

ParametricPlot3D[helikoid[2, 1/2][u, v] // Evaluate, {u, Pi, 
        15  Pi/2, Pi/24}, {v, 0, 3, 3}, ViewPoint -> {1, 2, 1}]

ParametricPlot3D[
      Append[helikoid[2, 1/2][u, v], Hue[u/(8  Pi)]] // Evaluate, {u, 
        Pi, 8  Pi, Pi/24}, {v, 0, 3, 3}, ViewPoint -> {1, 2, 1}, 
      Lighting -> False]

ParametricPlot3D[helikoid[2, 1/2][u, v] // Evaluate, {u, Pi, 
        15  Pi/2, Pi/24}, {v, -3, 3}, ViewPoint -> {1, 2, 1}]

ParametricPlot3D[
      Append[helikoid[2, 1/2][u, v], FaceForm[Hue[0.5], Hue[0.15]]] // 
        Evaluate, {u, Pi, 15  Pi/2, Pi/24}, {v, -3, 3}, 
      ViewPoint -> {1, 2, 1}, 
Lighting -> 
        False]

Show[
      Table[ParametricPlot3D[helikoid[2, 1/2][u, v] // Evaluate, {u, i, 
            i + Pi/42, Pi/42}, {v, -1, 1, 0.2}, 
          DisplayFunction -> Identity], {i, Pi, 4  Pi, Pi/24}], 
      DisplayFunction -> $DisplayFunction]

Show[
      Table[ParametricPlot3D[helikoid[2, 1/2][u, v]
 // 
            Evaluate, {u, Pi, 4  Pi, Pi/42}, {v, i, i + 0.05, 0.05}, 
          DisplayFunction -> Identity], {i, -1, 0.95, 1.95/11}], 
      DisplayFunction -> $DisplayFunction]

Show[%, %%]

Show[
      Table[ParametricPlot3D[
          Append[helikoid[2, 1/2][u, v], Hue[u/(4  Pi)]] // 
            Evaluate, {u, i, i + Pi/42, Pi/42}, {v, -1, 1, 1}, 
          DisplayFunction -> Identity, Lighting -> False], {i, Pi, 
          4  Pi, Pi/24}], 
      DisplayFunction -> $DisplayFunction]

Show[
      Table[ParametricPlot3D[
          Append[helikoid[2, 1/2][u, v], 
If[
                i == -1, Hue[1], Hue[0.3]]] // Evaluate, {u, Pi, 
            4  Pi, Pi/42}, {v, i, i + 0.05, 0.05}, 
          DisplayFunction -> Identity, 
          Lighting -> False], {i, -1, 0.95, 1.95}], 
      DisplayFunction -> $DisplayFunction]

Show[%, %%]

rothiperboloid1[a_, b_][u_, v_] := {a*Cosh[v]*Cos[u], 
        a*Cosh[v]*Sin[u], b*Sinh[v]}

Show[
      Table[ParametricPlot3D[rothiperboloid1[3, 4][u, v] // Evaluate, {u, 
            i, i + Pi/24, Pi/24}, {v, -1, 1}, 
          DisplayFunction -> Identity], {i, 0, 2  Pi, 
          Pi/12}], 

Table[
        ParametricPlot3D[rothiperboloid1[3, 4][u, v] // Evaluate, {u, 0, 
            2  Pi, Pi/24}, {v, i, i + 0.1, 0.1}, 
          DisplayFunction -> Identity], {i, -1, 1, 
          0.2}], 

DisplayFunction -> $DisplayFunction]

4.2.2. PointParametricPlot3D

PointParametricPlot3D[helikoid[2, 1/2][u, v] // Evaluate, {u, Pi, 
        15  Pi/2, Pi/24}, {v, 0, 3}, ViewPoint -> {1, 2, 1}]

4.2.3. SphericalPlot3D

SphericalPlot3D[4, {v, 0, Pi, Pi/24}, {u, 0, 2  Pi, Pi/24}]

4.2.4. CylindricalPlot3D

CylindricalPlot3D[-Sqrt[25 - r^2], {r, 0, 5, 0.2}, {u, 0, 2  Pi, 
        Pi/24}]

4.3. paket Graphics3D

4.3.1. ScatterPlot

<< Graphics`Graphics3D`

ScatterPlot3D[{{0, 0, 2}, {0, 4, 4}, {4, 
          4, -1}}, 
PlotStyle -> {AbsolutePointSize[8]}]

lista = 
        Table[{t*Cos[t], t*Sin[t], t/2}, {t, -6 Pi, 0, 
            Pi/24}];

ScatterPlot3D[lista]

ScatterPlot3D[lista, 
      PlotJoined -> 
        True, 
PlotStyle -> {AbsoluteThickness[2], 
          Hue[1]}]

4.3.2. StackGraphics

PersejKriv[p_, d_, R_][x_, 
        y_] := 
(x^2 + y^2 + p^2 + d^2 - R^2)^2 - 
        4  d^2 (x^2 + p^2)

<< Graphics`ImplicitPlot`

Table[
ImplicitPlot[PersejKriv[p, 3, 2][x, 
            y] == 0, {x, -5, 5}, 
        PlotStyle -> {AbsoluteThickness[2], Hue[p/6]}, 
        DisplayFunction -> Identity], {p, 0, 4.5, 0.5}]

Show[StackGraphics[%]]

Show[StackGraphics[%%], BoxRatios -> {1, 5, 1}]

4.3.3. ShadowPlot3D

ShadowPlot3D[Sin[2x*y],{x,0,3},{y,0,3}]

ShadowPlot3D[Sin[2x*y],{x,0,3},{y,0,3},PlotPoints->40]

ShadowPlot3D[Sin[2x*y],{x,0,3},{y,0,3},PlotPoints->40,ShadowPosition->1]

4.3.4. Shadow

rothiperboloid1[a_, b_][u_, v_] := {a*Cosh[v]*Cos[u], 
        a*Cosh[v]*Sin[u], b*Sinh[v]}

hip = 
      ParametricPlot3D[rothiperboloid1[3, 4][u, v] // Evaluate, {u, 0, 
          2  Pi}, {v, -1, 1}]

Shadow[hip]

Shadow[hip, YShadow -> False, ZShadowPosition -> 1, 
      AxesLabel -> {x, y, z}]

4.3.5. Project

Show[Project[hip, {1, 1, 0}]]

Show[Project[hip, {0,0,1}]]

Show[Project[hip, {0,-1,1}]]

Show[
Project[
hip,{{0,1,0},{-1,0,1}},{1,0,0}],
AxesLabel->{x,y,z}]

Show[
Project[
hip,{{0,1,0}, {-1, 0, 1}},{0,0,0},{1,1,1}],
AxesLabel->{x,y,z}]

4.4. paket Animation

4.4.1. MoviePlot3D

<< Graphics`Animation`

MoviePlot3D[Sin[n*x*y], {x, 0, 4}, {y, 0, 4}, {n, -2, 2, 0.25}, 
      PlotRange -> {{0, 4}, {0, 4}, {-1, 1}}, 
      PlotPoints -> 50]

4.4.2. SpinShow

plucker =
ParametricPlot3D[{r*Cos[u], r*Sin[u],Sin[2u]},
      {r,0,3}, {u,0,2Pi,Pi/24},
      Axes -> False, Boxed -> False]

SpinShow[plucker,
Frames -> 10,
SpinRange -> {0 Degree, 180 Degree}]

SpinShow[plucker,
Frames -> 10,
SpinRange -> {0 Degree, 180 Degree},
SpinOrigin->{0,0,-0.5},
SpinDistance->2,
RotateLights->True]

SpinShow[plucker,
Frames -> 10,
SpinRange -> {0 Degree, 180 Degree},
SpinTilt->{180,0}]

Clear[plucker]

4.4.3. Animacije pomocu naredbe Table

plucker[n_][r_,u_]:=ParametricPlot3D[{r*Cos[u], r*Sin[u],Sin[n*u]},{u,0,2Pi,Pi/(12*n)},{r,0,3},
Boxed->False,Axes->False]

plucker[2][r, u]

plucker[3][r, u]

Table[plucker[n][r, u], {n, 2, 10, 1}]