# Create a star system fit to conic equation

For simulation purposes, I'm trying to create a binary star system. If I have a conic equation such as $ax^2 + by^2 = c$, and the masses of two stars, how would I find the $x$- and $y$- velocity vectors (let's assume one star is the reference point, fixed in space), so that one star's orbit is stable and described by the conic equation?

• The equation for the tangent line to a conic section can be found here. Once you have the tangent vector, scale its length to give the correct speed. (There do exist other ways though, e.g. writing the conic equation in a suitable parametric form and differentiating). – lemon Mar 9 '15 at 19:47

The simplest solution is to find the center of mass of the two objects - at any moment in time, if the stars are a distance $d$ apart, and their respective masses as $m_1$ and $m_2$, then the center of mass is found at a distance $x$ from $m_1$ where

$$x = d \frac{m_2}{m_1+m_2}$$

From this you can see that if $m_1 >> m_2$, the center of mass will be "at" $m_1$, and when they are the same mass, it will be in the middle.

Once you have the center of mass, then the motion of each object relative to the center of mass follows a conic with the center of mass at the focus.

Relative to the focus, each star follows the vis viva equation:

$$v^2 = GM(\frac{2}{r} - \frac{1}{A})$$

where $A$ is the semimajor axis of the ellipse, $G$ is the gravitational constant, and $M$ is the sum of the masses (see for instance http://en.wikipedia.org/wiki/Specific_orbital_energy):

$$M = {m_1 + m_2}$$.

$$a x^2 + b y^2 = c$$
we compute the semimajor axis (the parameter $A$ in the vis viva equation) by determining the value of $x$ when $y=0$, and obtain
$$a A^2 = c\\ A = \sqrt{\frac{c}{a}}$$
Now the value of $r$ needed in the above equation is the distance between the two stars (not the distance to the focal point). You find that distance from your equation for the orbit, and so the total velocity for any point $(x,y)$ along the path follows. The direction is of course the tangent to the orbit.