Advertisement
Wojtekd

Untitled

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