How to get the longitude of the perihelion to find the Heliocentric Equatorial coordinates of a planet I'm writing a program to randomly generate star systems and I have been having a difficult time figuring this out. I've found the equations I need to get the heliocentric equatorial coordinates, but I haven't been able to figure out how to determine the longitude of perihelion. Is it just the opposite of the longitude of the ascending node or is it a completely different variable?

It might just me, but the names for this stuff is definitely making it more confusing than it should be.

Here is all my notes:

** = power

P = planet's period

a = semi-major axis

b = semi-minor axis

M = mean anomaly

E = Eccentric anomaly

e = eccentricity of orbit

v = true anomaly

r = radial distance

A = longitude of asending node

w = longitude of perihelion

i = inclination

t = time

(r, v) = polar coordinates

(x, y, z) = Heliocentric Ecliptic coordinates

(X, Y, Z) = Heliocentric Equalorial coordinates

eccentricity

e = sqrt(1 - (b ** 2 / a ** 2))

Period

P = sqrt(a ** 3)

Kepler's Equation

M = E - e * sin(E)

Mean Anomaly
use as starting point for eccentric anomaly

M = (2 * pi * t) / P

True Anomaly

v = 2 * atan(sqrt((1 + e) / (1 - e)) * tan(E / 2))

Radial Distance

r = (a(1 - e ** 2)) / (1 + e * cos(v))

Heliocentric Ecliptic coordinates

x = r(cos(A) * cos(w + v) - sin(A) * sin(w + v) * cos(i)

y = r(sin(A) * cos(w + v) + cos(A) * sin(w + v) * cos(i)

z = r * sin(w + v) * sin(i)

Heliocentric Equalorial coordinates

X = x

Y = y * cos(i) - z * sin(i)

Z = y * sin(i) + z * cos(i)
As opposed to what @user21 said, the longitude of periastron does depend on the longitude of ascending node (I was surprised by that myself).
In orbital dynamics, there exist the argument of periastron (symbol ω) as well as the longitude of periastron (symbol π [or ϖ but may lead to confusion) ), which is equal to the argument of periastron (ω) plus the longitude of ascending node (Ω). In other words:
π = ω + Ω
Now, the argument of periastron is equal to:
ω = arccos $\frac{\mathbf{n}\ ·\ \mathbf{e}} {|\mathbf{n}||\mathbf{e}|}$
If ez &lt; 0 then ω → 2π − ω.
where:
$\mathbf{n}$ is a vector pointing towards the ascending node (i.e. the z-component of $\mathbf{n}$ is zero), and
$\mathbf{e}$ is the eccentricity vector (a vector pointing towards the periastron).
This formula can be found at https://en.wikipedia.org/wiki/Argument_of_periapsis (I call it instead the “argument of periastron,” as Meeus says: “The word ‘periapse’, used by some authors, is incorrect. The word perihelion means the point of the orbit that is closest to the Sun [from the Greek peri = near + helios = Sun]. Similarly, perigee is the point closest to the Earth [ge = Earth]. Therefore, ‘periapse’ would really mean the point closest to the apse; but this is ridiculous, because what is meant is the apse itself!”)
So, using the above formula, you should be able to figure out the longitude of the ascending node for each of your hypothetical bodies.
Have fun!