• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

Math Help (Ellipses / Orbits / Eccentricity)

kaladorn

SOC-14 1K
Since I'd like to be able to graphically represent a system for players to actually do some tooling around in-system, I need to be able to map a system and have the objects in the system behave as I would expect them to ( including the fun issues of scaling, how orif I should handle out-of-plane orbits, drill-downs, etc).

Part of that is being able to map orbits of bodies. Now, a circular orbit around the primary is easy! (Too easy!)

However, not all orbits are circular. What I need to have is a formula that will allow me to create ellipsoid orbits (ie the formula for the ellipse, so I can draw the ellipse) knowing only the center point of the ellipse and the traveller standard orbital eccentricity figure.

What I am not is a geometry whiz and it has been many years since high school. Anyone care to offer a guess about the formula for an ellipse in the form of some set center coorinate (we'll call that Xc, Yc in two-space), the orbital radius (had it been a circular orbit) we'll call Rorb and an eccentricity we'll call Eorb.

Thanks in advance to any geometers out there.
 
The general form of the circle is x^2 + y^2=1
The general form of the ellipse is (x^2/a^2) + (y^2/b^2) = 1.

A and B above are the semi-major (longest) and semi-minor (shortest) radius of the ellipse from Xc, Yc. In your notation Eorb = sqrt(a^2-b^2)/a. A and B will both be about Rorb, the larger the difference the more eccentric the orbit.

Googling for Elliptical Orbit may give you better answers.
 
Hi Thomas,

this snippet constructs a fake ellipse.
I will supply a slighty modified code containing the correct formula tomorrow morning.
I normally just use trigonometry for display stuff cause its mostly good enough for that.

Differences to a real ellipse will be minimal.
I've implemeted some rotation algorithm too, because normally you will not have elliptical orientation chained to x or y direction.
So you can specify an angle and the thing turns around as you like.

Here we go:
--------------------------------------------
Public Sub E2(bx As Long, by As Long, dx As Long, dy As Long, angle As Long)
Const pi = 3.1415
Dim x As Long
Dim y As Long
Dim tw As Double
Dim tr As Long
Dim tx As Long
Dim ty As Long
For w = 1 To 360 Step 2
...x = Int(Cos(w * pi / 180) * dx)
...y = Int(Sin(w * pi / 180) * dy)
...' This rest is just for rotation
...tr = Sqr(x ^ 2 + y ^ 2)
...If not x = 0 Then
......If x GT 0 Then tw=(Atn(y/x)/pi)*180
......If x LT 0 Then tw=180+(Atn(y/x)/pi)*180
...End If
...tx = Int(Cos((tw + angle) * pi / 180) * tr)
...ty = Int(Sin((tw + angle) * pi / 180) * tr)
...pBox.PSet (bx + tx, by + ty), vbRed
Next w
End Sub
-----------------------------------------------
Please replace GT and LT in the if clauses by
> and <. The posting parser was upset about the original line.

It quick code, so there maybe are some inefficiencies.

Regards,

Mert
 
I was wondering about that. How eccentric does an orbit have to be before you'll start noticing on a system overview? I'd guess from the pictures I've seen of Sol system that there will be planets that the orbits are observably non-circular....
 
Originally posted by kaladorn:
I was wondering about that. How eccentric does an orbit have to be before you'll start noticing on a system overview? I'd guess from the pictures I've seen of Sol system that there will be planets that the orbits are observably non-circular....
The eccentricity has to be more than about 0.1 for it to be particularly noticeable, I think.

Other titbits...

The thing that the body orbits is located at one of the foci of the ellipse, not the centre of it.

Aphelion distance is given by a(1+e), Perihelion distance is given by a(1-e).

Major planetary bodies would orbit very close to a single plane (the ecliptic) in the system. Minor bodies will be spread more widely around this plane.
 
Didn't I mention the whole issue of in-the-plane or not? I'm not going to worry about projections or 3D models, I don't think. But knowing that e >= 0.1 starts to make a noticeable point is worthwhile.

And knowing that the foci (one of them) is the orbital centre point is useful too.

I just needed to have the equation to draw the elipse (shifting the center from between the foci to the foci is not a problem)


And any overhead view will presume that you are looking down on the plane of the ecliptic.

Thanks for the help folks.
 
Originally posted by kaladorn:
[QB] Didn't I mention the whole issue of in-the-plane or not? I'm not going to worry about projections or 3D models, I don't think. But knowing that e >= 0.1 starts to make a noticeable point is worthwhile.
Note that was a rough guess. I think you can see that Mercury and Pluto's orbits are noticably non-circular, and they're at around 0.2 and 0.25. But the orbits of the other terrestrial planets aren't so obviously non-circular, so presumably the critical value lies between about 0.1 and 0.2.

Have you seen Celestia, BTW? That's a very fine customisable solar system viewer... you can change just about everything in it. If you know enough orbital parameters, you could possibly use that to render your systems? it can be found at:
http://www.shatters.net/celestia/ , but the server seems to be a bit flaky as I write this. Well worth a look though.
 
Hello,

coding time again.
Here comes the mathematically correct implementation of the ellipse stuff:

Public Sub E3(bx As Long, by As Long, dx As Long, dy As Long, angle As Long)
Const pi = 3.1415
Dim x As Long
Dim y As Long
Dim y2 As Long
Dim tw As Double
Dim tr As Long
Dim tx As Long
Dim ty As Long

For x = -dx To dx Step 1
' postive y of ellipse
y = (dy / dx) * Sqr(dx ^ 2 - x ^ 2)
tr = Sqr(x ^ 2 + y ^ 2)
If x <> 0 Then
If x GT 0 Then tw = (Atn(y / x) / pi) * 180
If x LT 0 Then tw = 180 + (Atn(y / x) / pi) * 180
End If
tx = Int(Cos((tw + angle) * pi / 180) * tr)
ty = Int(Sin((tw + angle) * pi / 180) * tr)
pBox.PSet (bx + tx, by + ty), vbRed

' mirrowed negativ y of ellipse
y2 = -y
tr = Sqr(x ^ 2 + y2 ^ 2)
If x <> 0 Then
If x GT 0 Then tw = (Atn(y2 / x) / pi) * 180
If x LT 0 Then tw = 180 + (Atn(y2 / x) / pi) * 180
End If
tx = Int(Cos((tw + angle) * pi / 180) * tr)
ty = Int(Sin((tw + angle) * pi / 180) * tr)
pBox.PSet (bx + tx, by + ty), vbRed
Next x
End Sub

-------------------------------------------

I like the prior posted "fake" version a bit more, because its easier to plot a regular dotted line.....

Besides:
I have just finished a (very) prototyp system viewer. If you want to take a look give me a mail.
It accepts XML input like:

<StarSystem>
<Primary Type="Star" Name="Sun" Size="1,5">
<obj Type="Planet" Name="Alpha" Size="2" Orbit="1" />
<obj Type="Planet" Name="Beta" Size="4" Orbit="2" />
<obj Type="Planet" Name="Gamma" Size="2" Orbit="4">
<Satellite Type="Moon" Name="Twister" Size="3" Orbit="3"/>
<Satellite Type="Moon" Name="Ranger" Size="3" Orbit="4"/>
</obj>
<obj Type="Planet" Name="Delta" Size="2" Orbit="6" />
</Primary>
</StarSystem>

Well, it a prototype....


Regards,

Mert
 
Lord Kaladorn, there is a NASA film, entitled "Orbital Mechanics" that is an excellent resource on this... It is definitely not a film to watch at a party though... be that as it may, the film mathematically cuts to the chase, so to speak. I got it from a library, and I promise i didn't tape it...

omega.gif
 
Hi,

it worked well, so I would like to provide a little software - at least Kaledorns idea - which is able to show a zoomable stellar system with 10/100D radii included.

Anybody willing to take a look and to put it on his webspace ?

Regards,

Mert
 
Mert,

Mail me at kaladorn at magma dot ca. I can host it somewhere. But I'll want a good doc explaining installation and system requirements (ie if you did it in VB, make sure you package it with any required components or at least identify what those are and where to get them.... and that it won't support non-Windoze platforms). I want to do this in Java or just have something crank out jpegs so you don't need even java working to use it. And eventually import a version of TravXML. Cross platform is good.

Though I would like to see this version!

Tomb
 
One thing of interest - taking this thread a bit further...

Is there a way to determine where a given planet will be on an ellipsical orbit as compared against where a planet would be on a perfectly circular orbit with an eccentricity of zero? The further a planet is from the sun, the slower it is moving in its orbit. The faster the planet moves in orbit, the closer it is to the sun. Question is - how do you determine where a planet should be at any given time on an eliptical orbit?
 
Hal since a planet moves in it's obit such that equal areas of the ellipse are covered in equal times, I'd approach it by calculating 1/365th of the ellipse area, the use the calendar day, from some random "Start day" point.

Each orbit of a system might have different random "Starting days".

Then save each orbit, it's eccentricity, and "start day" point, then assuming no 3 body problem (for our purposes), you could calculate any position of any body, travel times at Specific G, etc, etc.

I think this is a good project for me to work on this month, in my spare time.

Maybe I can make it a plugin for Jim V's Galactic.
 
Back
Top