Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- r = 0.1;
- x0 = 0;
- y0 = 0;
- z0 = powierzchnia[x0, y0];
- listaKatow = Table[RandomReal[{0, 2 Pi}], {i, 100}];
- powierzchnia[x_, y_] = 2 x + 3 y^2;
- f[x_, y_, xp_, yp_,
- zp_] = (x - xp)^2 + (y - yp)^2 + (2 x + 3 y^2 - zp)^2 - r^2;
- i = 1;
- points = {};
- SeedRandom[1234];
- While[i <= 100, alfa = listaKatow[[i]];
- Result =
- Solve[{x, y} \[Element]
- InfiniteLine[{{x0, y0}, {x0 + Cos[alfa], y0 + Sin[alfa]}}] &&
- f[x, y, x0, y0, z0] == 0, {x, y}];
- xPunktu = Result[[1, 1, 2]];
- yPunktu = Result[[1, 2, 2]];
- zPunktu = powierzchnia[xPunktu, yPunktu];
- pointCurrent = {xPunktu, yPunktu, zPunktu};
- xPunktu2 = Result[[2, 1, 2]];
- yPunktu2 = Result[[2, 2, 2]];
- zPunktu2 = powierzchnia[xPunktu2, yPunktu2];
- pointCurrent =
- RandomChoice[{{xPunktu, yPunktu, zPunktu}, {xPunktu2, yPunktu2,
- zPunktu2}}];
- points = Append[points, pointCurrent];
- x0 = pointCurrent[[1]];
- y0 = pointCurrent[[2]];
- z0 = pointCurrent[[3]];
- i++;]
- Animate[Show[
- Plot3D[{2 x + 3 y^2}, {x, -1, 1}, {y, -1, 1},
- BoxRatios -> {1, 1, 1}],
- Graphics3D[{Green, PointSize[.02], Line[points[[;; it]]],
- Point[points[[it]]]}]], {it, 1, 100, 1}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement