Can a planet's orbit around a star be simulated? [closed]

Say I know all parameters like density, size, rotational velocity of a planet, could I predict its orbit around a star where I also know parameters of it? I want to design a simple model of the solar system as a practice of programming.

Say I had a 2D plane with a sun at the origin and a planet with known characteristics somewhere. What would I need to know to at least somewhat accurately plot its movement? Can a planet's orbit be deduced this way, say with a formula? If I can assume a planet is only affected by its star and not other planets.

closed as off-topic by ACuriousMind♦, Daniel Griscom, Gert, Norbert Schuch, AliJan 11 '16 at 6:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework-like questions should ask about a specific physics concept and show some effort to work through the problem. We want our questions to be useful to the broader community, and to future users. See our meta site for more guidance on how to edit your question to make it better" – ACuriousMind, Daniel Griscom, Gert, Norbert Schuch, Ali
If this question can be reworded to fit the rules in the help center, please edit the question.

• Specifically for plotting motion, how would that help? To give an arbitrary example, say I have a sun of size $x$ with density $y$, and a planet with size $w$ and density $z$. Sun is at 0,0, the planet is at some other point. I have the initial position of the planet, but what about its next position after all forces have acted upon it? – gator Jan 10 '16 at 16:58

1 Answer

This is known as the two-body problem of modeling the interactions of two bodies. More specifically, it is called the Kepler problem, as the objects interact via an inverse-square force - gravity.

If we define some parameter $u$ as $$u\equiv\frac{1}{r}\tag{1}$$ where $r$ is the radius of the orbit at some angle $\theta$, then, using the Euler-Lagrange equations, we eventually arrive at $$u=-\frac{GMm}{L^2}(1+e\cos(\theta-\theta_0))\tag{2}$$ where $M$ is the mass of the larger body, $m$ is the mass of the smaller body, $L$ is orbital angular momentum and $e$ is eccentricity. If you know the first three parameters, then $e$ can be calculated from the total energy of the orbit.

You don't need to know the density, size, or rotation of either body to model the orbit if you know the parameters give above.