嗨,我正在创建 3d 表面上的布朗运动模拟,所以我尝试将 3dplot 和动画功能联系起来。一切都在编译,没有任何错误,但我的问题是我想在表面上随机移动的球体没有显示(当然也没有动画)。可能是什么问题呢?这是代码:
Z[x_, y_] := 4 x + 3 y - 2
r = 0.05
Bok = 100
X[1] = RandomReal[{0, Bok}]
Y[1] = RandomReal[{0, Bok}]
Z[1] := Z[X1, Y1]
P[1] = Point[{X1, Y1, Z1}]
For[i = 1, i < 1000, i++, X[i + 1] = X[i] + RandomChoice[{0.1, -0.1}];
Y[i + 1] = Y[i] + RandomChoice[{0.1, -0.1}];
Z[i + 1] = Z[X[i + 1], Y[i + 1]];
P[i + 1] := Table[ Point[{X[i + 1], Y[i + 1], Z[i + 1]}], {i, 1000}];
(*Print[P[i+1]]*)
]
Animate[
Show[
Plot3D[Z[x, y], {x, 0, Bok}, {y, 0, Bok},
ColorFunction -> "DarkRainbow", Mesh -> None],
Graphics3D[
Black, Sphere[P[i], r]
]
],
{i, 1, 1000}
]