Advertisement
Wojtekd

Uogolnienie

Apr 14th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. r = 0.1;
  2. x0 = 0.7;
  3. y0 = 0.3;
  4. z0 = powierzchnia[x0, y0];
  5. listaKatow = Table[RandomReal[{0, 2 Pi}], {i, 100}];
  6. powierzchnia[x_, y_] = 2 x + 3 y^2;
  7. f[x_, y_, xp_, yp_,
  8.    zp_] = (x - xp)^2 + (y - yp)^2 + (2 x + 3 y^2 - zp)^2 - r^2;
  9.  
  10. alfa = listaKatow[[1]];
  11.  
  12. Result = Solve[{x, y} \[Element]
  13.      InfiniteLine[{{x0, y0}, {x0 + Cos[alfa], y0 + Sin[alfa]}}] &&
  14.     f[x, y, x0, y0, z0] == 0, {x, y}];
  15.  
  16. xPunktu = Result[[1, 1, 2]];
  17. yPunktu = Result[[1, 2, 2]];
  18. zPunktu = powierzchnia[xPunktu, yPunktu];
  19.  
  20. xPunktu2 = Result[[2, 1, 2]];
  21. yPunktu2 = Result[[2, 2, 2]];
  22. zPunktu2 = powierzchnia[xPunktu2, yPunktu2];
  23.  
  24. dlugosc = Sqrt[(xPunktu - x0)^2 + (yPunktu - y0)^2 + (zPunktu - z0)^2]
  25. dlugosc2 =
  26.  Sqrt[(xPunktu2 - x0)^2 + (yPunktu2 - y0)^2 + (zPunktu2 - z0)^2]
  27.  
  28. Show[
  29.  ContourPlot[{y*Cos[alfa] - x*Sin[alfa],
  30.    f[x, y, x0, y0, z0] == 0}, {x, -2., 2.}, {y, -2., 2.}],
  31.  Graphics[{{Blue,
  32.     InfiniteLine[{{x0, y0}, {x0 + Cos[alfa], y0 + Sin[alfa]}}]}, {Red,
  33.      Point[{x, y}] /. Result}}]
  34.  ]
  35.  
  36. Show[
  37.  Plot3D[{2 x + 3 y^2}, {x, -1, 1}, {y, -1, 1}, BoxRatios -> {1, 1, 1}],
  38.  Graphics3D[{Red, PointSize[.02], Point[{x0, y0, z0}]}],
  39.  Graphics3D[{Green, PointSize[.02],
  40.    Point[{xPunktu, yPunktu, zPunktu}]}],
  41.  Graphics3D[{Blue, PointSize[.02],
  42.    Point[{xPunktu2, yPunktu2, zPunktu2}]}],
  43.  Graphics3D[{Opacity[0.5], Sphere[{x0, y0, z0}, r]}]
  44.  ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement