Message Boards Message Boards

Simulate and visualize a solar planet's motion?

Posted 5 years ago

I want to simulate Solar Planet's motion with mathematica, so I typed like this. The Code

But there were some errors.

I can't figure out what is wrong and how to fix it. The Error

POSTED BY: Hojun Lee
4 Replies

Dear @Hojun Lee, Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

Please do not post code as images.

The rules explain how to format your code properly. If you do not format code, it may become corrupted and useless to other members. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

enter image description here

POSTED BY: Moderation Team

You did not put the curly braces. After the correction, we get the desired animation

G = 1; M = 1; \[Omega][r_] := Sqrt[G*M/r^3]; t0 = 4*Pi;
Animate[Graphics[{Red, Disk[{0, 0}, .2], Blue, 
   Disk[{Cos[\[Omega][1]*t], Sin[\[Omega][1]*t]}, .1], Brown, 
   Disk[{1.52*Cos[\[Omega][1.52]*t], 1.52*Sin[\[Omega][1.52]*t]}, .1],
    Black, Line[{{0, 0}, {Cos[\[Omega][1]*t], Sin[\[Omega][1]*t]}}], 
   Line[{{Cos[\[Omega][1]*t], 
      Sin[\[Omega][1]*t]}, {1.52*Cos[\[Omega][1.52]*t], 
      1.52*Sin[\[Omega][1.52]*t]}}]}, 
  PlotRange -> {{-2, 2}, {-2, 2}}], {t, 0, t0}]

enter image description here

Posted 5 years ago

Thank you very much.

POSTED BY: Hojun Lee

Inside Graphics the object should be gathered within curly brackets: Graphics[{....}].

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract