Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- M = 1; G = 1;h = 0.1; T = 1; n = T/h; (*steps*)
- NewtonGrav[{vx_, vy_, vz_, x_, y_, z_}] :=
- {vx + (-G M x)/Sqrt[x^2 + y^2 + z^2]*h,
- vy + (-G M y)/Sqrt[x^2 + y^2 + z^2]*h,
- vz + (-G M z)/Sqrt[x^2 + y^2 + z^2]*h,
- x + vx*h, y + vy*h, z + vz*h}
- DataNewton = NestList[NewtonGrav, {1, 1, 1, 1, 1, -1}, IntegerPart[n]];
- DataPlot = Table[Drop[DataNewton[[i]], 3], {i, 1, Length[DataNewton]}]
- {{1, 1, -1}, {1.1, 1.1, -0.9}, {1.19423, 1.19423, -0.794226},
- {1.28233, 1.28233, -0.683445}, {1.36404, 1.36404, -0.568408},
- {1.43913, 1.43913, -0.449845}, {1.50744, 1.50744, -0.328455},
- {1.56884, 1.56884, -0.204907}, {1.62326, 1.62326, -0.0798366},
- {1.67063, 1.67063, 0.0461538}, {1.71094, 1.71094, 0.172492}}
- Show[Graphics3D[Point[DataPlot[[1]]]],
- Graphics3D[Point[DataPlot[[2]]]], Graphics3D[Point[DataPlot[[3]]]],
- Graphics3D[Point[DataPlot[[4]]]], Graphics3D[Point[DataPlot[[5]]]],
- Graphics3D[Point[DataPlot[[6]]]], Graphics3D[Point[DataPlot[[7]]]],
- Graphics3D[Point[DataPlot[[8]]]], Graphics3D[Point[DataPlot[[9]]]],
- Graphics3D[Point[DataPlot[[10]]]], Graphics3D[Point[DataPlot[[11]]]]]
- Show[Graphics3D[Line[{DataPlot[[2]], DataPlot[[1]]}]] ,
- Graphics3D[Line[{DataPlot[[3]], DataPlot[[2]]}]] ,
- Graphics3D[Line[{DataPlot[[4]], DataPlot[[3]]}]] ,
- Graphics3D[Line[{DataPlot[[5]], DataPlot[[4]]}]] ,
- Graphics3D[Line[{DataPlot[[6]], DataPlot[[5]]}]] ,
- Graphics3D[Line[{DataPlot[[7]], DataPlot[[6]]}]] ,
- Graphics3D[Line[{DataPlot[[8]], DataPlot[[7]]}]] ,
- Graphics3D[Line[{DataPlot[[9]], DataPlot[[8]]}]] ,
- Graphics3D[Line[{DataPlot[[10]], DataPlot[[9]]}]],
- Graphics3D[Line[{DataPlot[[11]], DataPlot[[10]]}]]]
Add Comment
Please, Sign In to add comment