Jump to content

I have assumed direct control of the galaxy! (meaning I made a game about it)


Recommended Posts

Today I made something I thought was pretty cool and that I should share with you guys:

interactive__relativistic_space_travel_d

Play with it here! https://dl.dropboxusercontent.com/u/13276416/Unity/WarpTest/WarpTest.html

It's a little interactive "simulator" thing about relativistic space flight. I've made the galaxy much smaller than real life (only two light-minutes across) for obvious reasons, and it isn't quite scientifically accurate in all ways, but it's based on the real science behind relativistic optical effects and thus with any luck gives the right general impression. Here's hoping some of you guys have some fun with it!

And please be sure to let me know what you think.

Old post:

Spoiler

 

I've taken a break from KSP recently to derp around in Unity building a Spiral Galaxy Simulation showing, based on one of the leading theories, how the spiral structures of many galaxies form and persist despite varying orbit velocities of stars.

Currently it is able to accurately simulate the following:

- elliptical paths for the stars with one focus at the galactic core

- a non-random relation between the paths wherein they are "tilted" incrementally based on distance, creating the spiral effect

- varying speeds for orbits wherein stars that spawn closer to the nucleus move faster

- adjustable colors and other parameters allowing a variety of spiral shapes to be generated (these are not currently available in the above web player demo)

spiral_galaxy_simulation_by_parameciumkid-d91flcl.jpg

But there's one problem that continues to irk me, that being the fact that orbiting objects change speed within their orbit, moving faster as they approach periapsis and slower near apoapsis. I've been able to make each star change speed, but I've been stumped trying to pin down the relationship to use. Wikipedia and other physics sites I found via Google have been no help: some say that since the speed is dependent on position and vice versa, it cannot be solved by a traditional function and requires an infinite series; others gave me polar equations which seemed promising but got increasingly complicated in the process of implementing them.

Here's how things are currently implemented:

1. Calculate each star's "start" altitude (which ends up being its apoapsis; I can easily get the periapsis based on this)

2. Determine the star's mean orbital speed based on its start position

3. Calculate an angle ("t") based on the current time multiplied by the simulation speed and the star's mean speed, and add a pseudorandom value between 0 and 2 pi so that they don't all start in line

4. Use some function to adjust t so that the star moves at the appropriate speed. Currently the line of code is this: t -= Mathf.Sin(t) * eccentricity;

5. Use the sin and cosine of t and the eccentricity (an arbitrary value) to put the star on an ellipse. As time goes by and t changes, the star appears to move along the ellipse.

6. Rotate the position (and thus the resulting ellipse) based on the galaxy's "spiral power" to produce different types of spirals (low spiral power for Sc and high for Sa).

Everything is working wonderfully except for step 4. I need an equation of some kind for the star's speed based on its position in the orbit or the time since apoapsis (either works). Since the stars are all on fixed elliptical orbits, the simulation is independent of mass and velocity (for performance reasons if nothing else).

At first I thought this must be a sine or cosine function, but when I spawned a small ball and had it move on a physics-based orbital trajectory, I found that even at the same period and eccentricity, the ball would jump ahead at some points and fall behind at others - the speed of the ball, which I knew to be more realistic, was not following a sine wave.

Currently I'm wondering if the speed is based on a cycloid curve, but according to Wikipedia it is impossible to represent a cycloid as a function of x. An approximation would be sufficient, but here's where it got weird:

https://dl.dropboxusercontent.com/u/13276416/KSP/cycloid.jpg

As seen here, my best attempt to generate a cycloid is via what appears to be a fraction multiplied by a trigonometric function with an irrational exponent.

So I've come to my fellow Kerbtastic astrophysics nerds for help. I know KSP manages this to extreme precision, so it's at least theoretically possible. Does anyone know of a way to relate orbital speed to t? Or is there some other brilliant solution I haven't discovered?

 

 

Edited by parameciumkid
Stuffed the old post in a spoiler to hopefully not confuse people.
Link to comment
Share on other sites

I don't know how much it helps but this Wikipedia page goes through a method of computing position along an orbit as a function of time. It looks complicated though.

Link to comment
Share on other sites

I've taken a break from KSP recently to derp around in Unity building a Spiral Galaxy Simulation showing, based on one of the leading theories, how the spiral structures of many galaxies form and persist despite varying orbit velocities of stars.

Currently it is able to accurately simulate the following:

- elliptical paths for the stars with one focus at the galactic core

- a non-random relation between the paths wherein they are "tilted" incrementally based on distance, creating the spiral effect

- varying speeds for orbits wherein stars that spawn closer to the nucleus move faster

- adjustable colors and other parameters allowing a variety of spiral shapes to be generated (these are not currently available in the above web player demo)

http://orig15.deviantart.net/8721/f/2015/196/3/6/spiral_galaxy_simulation_by_parameciumkid-d91flcl.jpg

But there's one problem that continues to irk me, that being the fact that orbiting objects change speed within their orbit, moving faster as they approach periapsis and slower near apoapsis. I've been able to make each star change speed, but I've been stumped trying to pin down the relationship to use. Wikipedia and other physics sites I found via Google have been no help: some say that since the speed is dependent on position and vice versa, it cannot be solved by a traditional function and requires an infinite series; others gave me polar equations which seemed promising but got increasingly complicated in the process of implementing them.

Here's how things are currently implemented:

1. Calculate each star's "start" altitude (which ends up being its apoapsis; I can easily get the periapsis based on this)

2. Determine the star's mean orbital speed based on its start position

3. Calculate an angle ("t") based on the current time multiplied by the simulation speed and the star's mean speed, and add a pseudorandom value between 0 and 2 pi so that they don't all start in line

4. Use some function to adjust t so that the star moves at the appropriate speed. Currently the line of code is this: t -= Mathf.Sin(t) * eccentricity;

5. Use the sin and cosine of t and the eccentricity (an arbitrary value) to put the star on an ellipse. As time goes by and t changes, the star appears to move along the ellipse.

6. Rotate the position (and thus the resulting ellipse) based on the galaxy's "spiral power" to produce different types of spirals (low spiral power for Sc and high for Sa).

Everything is working wonderfully except for step 4. I need an equation of some kind for the star's speed based on its position in the orbit or the time since apoapsis (either works). Since the stars are all on fixed elliptical orbits, the simulation is independent of mass and velocity (for performance reasons if nothing else).

At first I thought this must be a sine or cosine function, but when I spawned a small ball and had it move on a physics-based orbital trajectory, I found that even at the same period and eccentricity, the ball would jump ahead at some points and fall behind at others - the speed of the ball, which I knew to be more realistic, was not following a sine wave.

Currently I'm wondering if the speed is based on a cycloid curve, but according to Wikipedia it is impossible to represent a cycloid as a function of x. An approximation would be sufficient, but here's where it got weird:

https://dl.dropboxusercontent.com/u/13276416/KSP/cycloid.jpg

As seen here, my best attempt to generate a cycloid is via what appears to be a fraction multiplied by a trigonometric function with an irrational exponent.

So I've come to my fellow Kerbtastic astrophysics nerds for help. I know KSP manages this to extreme precision, so it's at least theoretically possible. Does anyone know of a way to relate orbital speed to t? Or is there some other brilliant solution I haven't discovered?

The KSP model is very much simplified. Each planet has a spherical SOI and does not show deviations like L1 and L2 orbits. The devs have no desire to change this model, its a moot subject.

Your ball should not move in a precise ellipse. The only way it moves in a precise ellipse is a two body problem. Mass is moved to a point at the center of the galaxy. In a spiral galaxy masses are surrounded by matter, in fact even at the furthest radius stars are still interacting with dark matter. N-body problems of the galactic scale are not solvable, and this does not factor in unknowns like:

1. red dwarfs with current technology are only visible at close distances to the observer, many go undetected

2. Neutron stars and such are virtually invisible past a certain age, you would need a graviton telescope to see them.

3. Gas dust and protoplanetary disks may only be visible in the late stages of star genesis. Of course the nebula from which they from are with the proper level of backlighting stars.

4. Most of what is in the Kuiper belt and the Oort cloud is invisible to us.

You should look up papers on the deviation of star motion from predicted in the Milky Way, it is one of the factors that supported the existence of dark matter.

Link to comment
Share on other sites

^ All of this is true, but this being intended basically just for aesthetics, I'm fine with (I'd actually prefer) simplifying it to KSP's level of precision or lower. I've already assumed two-body orbits, and even that the star mass is negligible, making it sort of a one-body problem.

So what I'm looking for is an approximation to orbit position over time in a simplified stable two-body elliptical orbit, which to me seems like it shouldn't be anything grossly complicated.

Also I already read the Wikipedia page on Kepler's laws and if I recall properly that's the one that threw an infinite series at me xD

According to this page, the function is somewhere between a sine curve and a cycloid, but I can't quite pin down an equation for it. I've also tried these, and while fairly close they still don't seem to match.

Edited by parameciumkid
Link to comment
Share on other sites

One of the features of the real galaxy is that the orbital velocities of stars is emphatically NOT what one would expect from a simplistic application of Keplers laws of motion/Newtonian physics applied to each and every star in the galaxy. One would expect that the orbital velocities woudl drop off towards teh edge in exactly teh same way as you'd get in a classic two-body system with a relatively lightweight body orbiting a relatively heavy central object. Instead, a graph of the actual orbital velocities shows, if anything, a somewhat rising orbital velocity, the further one gets from the core of the galaxy. This discrepancy was the first indicator that what we can see of the universe is far being all that there actually is, and this is how the various theories about 'dark matter' gained their starting point. Also, last I read on the subject (it's been some years now), the spiral arm structures were thought to be caused by a sort of gravity wave. That is, that stars get sucked backwards towards a spiral arm as it approaches, pass through the arm, then get dragged forwards by teh retreating arm as it pushes on ahead (or vice versa - cant; recall which, it makes sense either way).

All of whcih means that unless you're doing an N-body simulation for a reasonably high number of N masses (including teh unseen dark matter ones) , what you get out of your simulation, whilst it may look like a spiral galaxy, will not be a good simulation of the real thing.

That said, if i had the know-how to create such a simulation, I'd still do it out of sheer curiosity, ultra-realisticphysics or no. :-)

https://en.wikipedia.org/wiki/Galaxy_rotation_curve for a wikipedia article on the rotation of the galaxy.

Link to comment
Share on other sites

Currently, no. I'm just toying with some space stuff in my spare time.

I could try to make a procedural universe, but with stuff like SpaceEngine, Elite: Dangerous, and No Man's Sky out there already I'd have to quit school and start working full-time to come up with something that'd stand out. Maybe in a few years :\

Link to comment
Share on other sites

Trying to simulate forces and potential energy would be hardware consuming. I think you should look at some formulation of density waves (spirals) propagation in galaxies, then adding this perturbation to the standard newtonian orbits of the stars. Kind of a "slower day" addition to the simulation.

Link to comment
Share on other sites

4. Use some function to adjust t so that the star moves at the appropriate speed. Currently the line of code is this: t -= Mathf.Sin(t) * eccentricity;
Everything is working wonderfully except for step 4. I need an equation of some kind for the star's speed based on its position in the orbit or the time since apoapsis (either works). Since the stars are all on fixed elliptical orbits, the simulation is independent of mass and velocity (for performance reasons if nothing else).

I think the problem you're is running into, stems from the fact that the motion of these objects is being simulated on a computer. In real life, the object's velocity would be constantly changing--and computers can't do that. At any given point in time, a computer can only store a fixed value for where an object is, what direction it's going, and at what speed. And a computer can only change those fixed numbers into other fixed numbers.

Instead of using an equation for a star's speed based on its position, how about an equation for its position based on its orbit? That equation should be able to spit out the star's precise position at any point in time--which IS a fixed number the computer can store without introducing any errors into the motion of the star. Then you can "tick" the simulation forwards in time, precisely positioning each star at each tick.

Unless, of course, your simulation is trying to simulate the gravity of all the stars on each other. In which case, just pretend I didn't post anything. :D

Link to comment
Share on other sites

Again, exactly what I tried to do ^^;

I presumed that since the orbit was prescribed and fixed, and therefore all orbital elements were known (and several were zero, e.g. inclination), a simple function would exist that would give me the object's position at a given time. From this I could easily simulate speed by simply assigning it the appropriate position each frame.

However, as best I can tell, such a function does not actually exist. Apparently orbits of different eccentricities follow markedly different patterns of motion, and the eccentricity affects the true anomaly (position at a given time) in a strange, unconventional manner. The eccentricity factors in, then the square of the eccentricity factors in a smaller amount, then the cube factors in an even smaller amount, etc. etc. etc. Orbital prediction software (such as KSP, presumably) uses a finite number of "iterations" using the eccentricity to estimate an object's position, and can be made to be precise to very small distances, but it seems to be the case that an exact solution is impossible using existing math.

I suppose this might be part of the reason New Horizons was only able to estimate its arrival time at Pluto to within several hours. :\

Link to comment
Share on other sites

Probably you can use mean anomaly instead ? Some calculation needed to tell the true anomaly through, via eccentric anomaly first.

Edited by YNM
Link to comment
Share on other sites

Heh.

Once again... tried that xD

The mean anomaly is extremely easy to calculate - in fact one could say I'm already using it. It simply increases linearly with time and is equivalent to an angle, the same thing represented by "t" in the code i posted. However, the eccentric and true anomalies derive from it in the bizarre manner detailed above, and for now I've given up.

Link to comment
Share on other sites

Again, exactly what I tried to do ^^;

I presumed that since the orbit was prescribed and fixed, and therefore all orbital elements were known (and several were zero, e.g. inclination), a simple function would exist that would give me the object's position at a given time. From this I could easily simulate speed by simply assigning it the appropriate position each frame.

In the real galaxy, stellar orbits are not fixed due to their gravitational interaction with each other both individually and en masse. Personally, I think it'd be interesting just to come up with something that creates something reasonably close to the right sort of pattern, never mind whethe rthe algorithm used actually properly models real-life factors.

Going off on a bit of a tangent, it's only just ocurred to me - and I can scarcely believe it;s tken me so long to think of this - that if the stars are all orbiting the galactic centre at approximately the same velocity, that makes things really interesting with regard to the momentum of each star , particularly if the periapsis and apoapsis about the galatic core are markedly different. Hmmmmnn...

Link to comment
Share on other sites

Don't forget the dark matter!

(This should help.)

https://en.wikipedia.org/wiki/Galaxy_rotation_curve

That's the link I quoted earlier, Queso. The problem with trying to simulate the dark matter is that AFAIK no-one (or very few, at least) are sure how. Doing so would, I think, be somewhat worse than trying o simulate the huge n-body problem of simply trying to model teh forces acting on individual stars.

Anyway, I was simply saying that, considering how long I've known about the flat rotation curve of the galaxy and the dark matter theory that arose from it (I can recall both being reported to the general public), I'm surprised that it didn;t occurrr to me to wonder about what happens to the inertia and momentum of the stars as they orbit in their decidedly peculiar way.

Link to comment
Share on other sites

That's the link I quoted earlier, Queso. The problem with trying to simulate the dark matter is that AFAIK no-one (or very few, at least) are sure how. Doing so would, I think, be somewhat worse than trying o simulate the huge n-body problem of simply trying to model teh forces acting on individual stars.

Anyway, I was simply saying that, considering how long I've known about the flat rotation curve of the galaxy and the dark matter theory that arose from it (I can recall both being reported to the general public), I'm surprised that it didn;t occurrr to me to wonder about what happens to the inertia and momentum of the stars as they orbit in their decidedly peculiar way.

You can model dark matter in the same way they model electron density for molecular orbitals. There was a paper written recently that actually shows that dark matter doesn't exactly avoid matter, it is simply indifferent to its existance except via gravitational forces, as a consequence it tends to concentrate as well around gravitational clusters as point masses and thus there should be an intersteller density profile that can be developed. You note that matter stratifies itself in objects (solid dense cores, less dense mantle crust, atmosphere, interplanetary space), dark matter just flies right through this as if it does not exist, very fast and then slows down and lingers in interstellar space. A good example would be an SP3 orbital of a C-H bond where the electron speeds alot of time (in a classic model, not the proper quantum mechanical model - which we know that the position of the electron is not defined until we try to observe it) lingering between C and H and a small amount of time in the nucleus and on the other side of the atom. In this case we can propose that for 1000 bonds the electrons are at distances from the nucleus 0-.1A, .1A to .2A, but given quantum mechanics its quite unneccesary to do that we don't ever need to know the exact position of the electron, just its probabilities. In the same way since dark matter is indifferent to matter and since it appears to be composed of isolated darkmatter, and not clumps of matter, you really do not need to know positions, just probabilities.

We have to think about it this way, if dark matter is say (just saying) half the mass of a galaxy, but exists not only where stars are but also where stars aren't such as in the extremes and well above and below the galactic plane, then its average density in a spiral arm relative to matter is much lower. Then we factor in the density between stars versus within the sun's heliosphere. And then you reach a realization is that the amount of dark matter in a stellar system is a tiny fraction of the dark matter in the galaxy.

Link to comment
Share on other sites

  • 4 months later...

Okay apparently I made it confusing reusing the thread and leaving the old post up there. Ahem.

I've "solved" (more or less) the problem with orbital velocities. Going by the multiple citations of actual galaxy rotation curves and their disobedience of Keplerian motion, I decided to leave out that part of the simulation. Now we have a NEW thing to talk about!

interactive__relativistic_space_travel_d

Details in OP.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...