## Orbits

**Forum rules**

-This forum is about the mechanics and framework of the content. NOT about the content itself, that belongs in phase 3. However, if content discussion creeps in because it is necessary, this is permissible.

- fr0stbyte124
- Developer
**Posts:**727**Joined:**Fri Dec 07, 2012 3:39 am**Affiliation:**Aye-Aye

How objects will orbit has been a frequent topic on the MC forum as of late, and I think it is worth it to review the current gameplan. I don't have a lot of time right now so I'll try to be brief and follow up a bit later.

The most prominent thing about the Futurecraft universe is there is no central coordinate system, and having one would be impractical if not impossible. Every object is bound to a frame of reference such as a ship or a planet or a fleet or some arbitrary point in space, and that frame of reference can be an offset to yet another frame and so on until all frames of reference share a common point, typically the center of the solar system. Finding relative coordinates is as simple as traversing the tree and applying transformations as you go. Since the frames are grouped by locality, you rarely need to look very far. Each frame of reference additionally might have a velocity, such as an orbit around a planet or a sun that can change over time depending on its nature.

That's all fine and good, but non-orbiting objects need a baseline velocity as well so that we can implement top speeds and slowing down the way a player would expect (instead of how it would work IRL). We can do that using a formula to work out what a reasonable baseline is for any point in the solar system. It is a similar concept to a gravitational field, in which the natural path of an object is curved by the presence of gravity wells. If we can mesh the two well, we can simulate orbits based on an object's local velocity.

This part needs some tweaking, because as it is, the local velocity zero relative to the nearest natural satellite and blends as you move towards others. This is fine if you want to move freely about the object, and you sometimes will, but if you need to orbit, such as around a planet, a velocity of 0 wont work, because you have an infinite number of vectors upon which you can be orbiting. So orbiting needs a velocity other than 0 to stay afloat, and not-orbiting should have a local velocity of 0. If we mix the force of gravity on planets and natural satellites, we may be able to resolve this conflict. If you were, say moving to dock with a space station, your velocity baseline would be the same as the station, which is stationary from that frame of reference. However, that frame of reference is orbiting the planet at a required velocity. As long as you are interracting in the vicinity of the station, your top speed is relative to the space station. When you break away and orbit the planet, your baseline speed is based on the altitude needed to maintain that orbit (I am assuming perfectly circular orbits to keep things simple). However, unlike before, your direction is ignored.

Because your baseline changes as you change your altitude, you never hit your top speed where you can't ascend any higher.

That's for natural orbits, though, meaning you will continue in this orbit if you cut the engines. You can travel faster along a natural orbit by accelerating into the curve, which produces a new velocity which is not 0m/s. That is the part where your top speed comes into play, and if you are flying around with other people, it should result in you being able to move freely around them almost like in deep space. The complex differences of handling the gravity well can be left up to the ship AI (or do it manually if you didn't include that module).

When I get a little bit of time, I want to try and work out the math on paper, at least in 2D.

The tl;dr thing to take away from this is that you should be able to move relatively freely regardless of where you are, and you should always have a stationary speed and a top speed which are relevant to wherever you are. If we can preserve these two things, we win.

P.S. One significant exception. When you hit atmosphere, air resistance becomes a major player and your top speed is sharply reduced and the frame of reference becomes the planet's surface. If the orbiting formula is correct, if you can't maintain your orbiting velocity (which drags more and more the closer to the surface you get), you will drop out of the sky unless you can counter with sufficient upward acceleration. If implemented properly, this will make it so that giant ships will naturally not be able to enter the atmosphere, and need to use other means to get to and from the surface.

The most prominent thing about the Futurecraft universe is there is no central coordinate system, and having one would be impractical if not impossible. Every object is bound to a frame of reference such as a ship or a planet or a fleet or some arbitrary point in space, and that frame of reference can be an offset to yet another frame and so on until all frames of reference share a common point, typically the center of the solar system. Finding relative coordinates is as simple as traversing the tree and applying transformations as you go. Since the frames are grouped by locality, you rarely need to look very far. Each frame of reference additionally might have a velocity, such as an orbit around a planet or a sun that can change over time depending on its nature.

That's all fine and good, but non-orbiting objects need a baseline velocity as well so that we can implement top speeds and slowing down the way a player would expect (instead of how it would work IRL). We can do that using a formula to work out what a reasonable baseline is for any point in the solar system. It is a similar concept to a gravitational field, in which the natural path of an object is curved by the presence of gravity wells. If we can mesh the two well, we can simulate orbits based on an object's local velocity.

This part needs some tweaking, because as it is, the local velocity zero relative to the nearest natural satellite and blends as you move towards others. This is fine if you want to move freely about the object, and you sometimes will, but if you need to orbit, such as around a planet, a velocity of 0 wont work, because you have an infinite number of vectors upon which you can be orbiting. So orbiting needs a velocity other than 0 to stay afloat, and not-orbiting should have a local velocity of 0. If we mix the force of gravity on planets and natural satellites, we may be able to resolve this conflict. If you were, say moving to dock with a space station, your velocity baseline would be the same as the station, which is stationary from that frame of reference. However, that frame of reference is orbiting the planet at a required velocity. As long as you are interracting in the vicinity of the station, your top speed is relative to the space station. When you break away and orbit the planet, your baseline speed is based on the altitude needed to maintain that orbit (I am assuming perfectly circular orbits to keep things simple). However, unlike before, your direction is ignored.

Because your baseline changes as you change your altitude, you never hit your top speed where you can't ascend any higher.

That's for natural orbits, though, meaning you will continue in this orbit if you cut the engines. You can travel faster along a natural orbit by accelerating into the curve, which produces a new velocity which is not 0m/s. That is the part where your top speed comes into play, and if you are flying around with other people, it should result in you being able to move freely around them almost like in deep space. The complex differences of handling the gravity well can be left up to the ship AI (or do it manually if you didn't include that module).

When I get a little bit of time, I want to try and work out the math on paper, at least in 2D.

The tl;dr thing to take away from this is that you should be able to move relatively freely regardless of where you are, and you should always have a stationary speed and a top speed which are relevant to wherever you are. If we can preserve these two things, we win.

P.S. One significant exception. When you hit atmosphere, air resistance becomes a major player and your top speed is sharply reduced and the frame of reference becomes the planet's surface. If the orbiting formula is correct, if you can't maintain your orbiting velocity (which drags more and more the closer to the surface you get), you will drop out of the sky unless you can counter with sufficient upward acceleration. If implemented properly, this will make it so that giant ships will naturally not be able to enter the atmosphere, and need to use other means to get to and from the surface.

### Re: Orbits

Well see what I think design wise - does it really matter ? What it makes the player feel hot or cold if the planets rotate or not ? I really think this is unnecessary for what we are trying to make, if it will speed up the process to remove it and wont impact the quallity of gameplay I don't think we should work on it, the same goes for realistically descending onto planets, the player really really wont care if he gets a loading screen for a minute just like in any other game.

They're watching ...

*"I am forbidden tag" -CvN*### Re: Orbits

I'm not sure you read that, Iv.

;.'.;'::.;:".":;",,;':",;

*(Kzinti script, as best as can be displayed in Human characters, translated roughly as "For the Patriarchy!")*### Re: Orbits

I read that and I speak in general it was jsut an example, I also include all that relative co-ordinate system etc.

It will be hard for the palyer to work with that unless it is all happening seemlessly but in that case what's the point if it is seemless and feels wholy identical ?

It will be hard for the palyer to work with that unless it is all happening seemlessly but in that case what's the point if it is seemless and feels wholy identical ?

They're watching ...

*"I am forbidden tag" -CvN*- fr0stbyte124
- Developer
**Posts:**727**Joined:**Fri Dec 07, 2012 3:39 am**Affiliation:**Aye-Aye

### Re: Orbits

At the very minimum, planets need to rotate because the sun is an actual thing in the sky you can go and visit. If planets rotate, then at the very least ships moving above them need to be able to to move along with the surface so they don't get stuck in a situation where they zip along going west but can't keep up going east. If ships can move along with a rotating planet, then at what point do they stop moving along with it?

Once you begin compensating for those things, you don't really end up saving anything by making a few parts stationary.

Actually, the more I think about it, the more elegant the gravity well system becomes. Forget about basing the local velocities surrounding velocities. Everything in the solar system traces out a circle around something else. Using the sun in this example, any two people will have the same relative motion if they are the same distance from the sun and tracing the same circle. Even if they are not next to each other, everyone on that circle is stationary to one another. There's your baseline. Everyone has one and it is easy to calculate. If something is naturally orbiting the sun, your baseline will naturally assume the same velocity when you get near its circle. On the scale of the solar system, you couldn't even perceive the curve you take to approach nearby objects.

I still need to run the numbers to see what acceleration towards and away from the gravity well is like, but I think this will work.

Once you begin compensating for those things, you don't really end up saving anything by making a few parts stationary.

Actually, the more I think about it, the more elegant the gravity well system becomes. Forget about basing the local velocities surrounding velocities. Everything in the solar system traces out a circle around something else. Using the sun in this example, any two people will have the same relative motion if they are the same distance from the sun and tracing the same circle. Even if they are not next to each other, everyone on that circle is stationary to one another. There's your baseline. Everyone has one and it is easy to calculate. If something is naturally orbiting the sun, your baseline will naturally assume the same velocity when you get near its circle. On the scale of the solar system, you couldn't even perceive the curve you take to approach nearby objects.

I still need to run the numbers to see what acceleration towards and away from the gravity well is like, but I think this will work.

### Re: Orbits

Well frost tell me how did we deal with that before ? Oh yeah, the planet was an independent unit from the ships and could rotate however it wants, the player ship will be in the same pos enjoying the planet passing by it instead of being stationary over one point. or even better - because of the gravity well system the sun and a planet will never ever be present in the same space at the same time - as a result you can make a fake sun rotate around the planet and a fake planet rotate around the sun, easy and it look wholly identical for the player to real rotation because he can never ever see both objects together.

They're watching ...

*"I am forbidden tag" -CvN*- fr0stbyte124
- Developer
**Posts:**727**Joined:**Fri Dec 07, 2012 3:39 am**Affiliation:**Aye-Aye

### Re: Orbits

Like I said, if the ship is stationary and the planet is rotating, you would have to be firing your engines just to stay in geosynchronous orbit, and you would move faster in one direction than the opposite. You can solve that without orbit mechanics.

I'm doing math now.

We need two velocity components, one tangent to the orbit and one perpendicular.

A natural orbit will have no perpendicular velocity and the tangential velocity of

where μ is a constant derived from the strength of the gravity well. It doesn't matter what it is because it will need to be tweaked no matter what.

The associated base acceleration from centripetal force is

Getting more complicated, to maintain an orbit while traveling Δv faster than neutral, you need additional inward acceleration Δa of

That is assuming you've reached either your top speed or top acceleration, whichever comes first. While getting up to that speed, your acceleration must be divided between inward and lateral components. Keep in mind that these numbers are only used internally to work out speed and acceleration. All the player will see is that they are maintaining their heading and what their course velocity (Δv) is.

Still trying to work out the equation for perpendicular course adjustments, but it seems to depend on how much of your tangential velocity you retain. The net energy difference seems to be

But that doesn't seem quite right to me. I'll try running some simulations later.

I'm doing math now.

We need two velocity components, one tangent to the orbit and one perpendicular.

A natural orbit will have no perpendicular velocity and the tangential velocity of

where μ is a constant derived from the strength of the gravity well. It doesn't matter what it is because it will need to be tweaked no matter what.

The associated base acceleration from centripetal force is

Getting more complicated, to maintain an orbit while traveling Δv faster than neutral, you need additional inward acceleration Δa of

That is assuming you've reached either your top speed or top acceleration, whichever comes first. While getting up to that speed, your acceleration must be divided between inward and lateral components. Keep in mind that these numbers are only used internally to work out speed and acceleration. All the player will see is that they are maintaining their heading and what their course velocity (Δv) is.

Still trying to work out the equation for perpendicular course adjustments, but it seems to depend on how much of your tangential velocity you retain. The net energy difference seems to be

But that doesn't seem quite right to me. I'll try running some simulations later.

### Re: Orbits

That is not KSP you know , you target for the Mun and shoot past it into deep space on the sun's escape velocity ...

All those calculations will be meaningless if what the players see is absolutely identical.

All those calculations will be meaningless if what the players see is absolutely identical.

They're watching ...

*"I am forbidden tag" -CvN*- fr0stbyte124
- Developer
**Posts:**727**Joined:**Fri Dec 07, 2012 3:39 am**Affiliation:**Aye-Aye

### Re: Orbits

Yeah, these are completely different rules. This pretends all orbits are perfectly circular and no matter how you move you will stabilize back to a circular orbit.

What I'm trying to work out now is what is happening when you fire your rockets to cancel out all lateral velocity,so you essentially start plummeting towards the planet. As you get closer, your lateral velocity will get further and further negative (because 0 is a stable orbit), which means you are accelerating, but that's not supposed to happen. If you get close enough, your acceleration and top speed will exceed your maxes despite you not using any power. That's not supposed to happen, but I can't think of what

What I'm trying to work out now is what is happening when you fire your rockets to cancel out all lateral velocity,so you essentially start plummeting towards the planet. As you get closer, your lateral velocity will get further and further negative (because 0 is a stable orbit), which means you are accelerating, but that's not supposed to happen. If you get close enough, your acceleration and top speed will exceed your maxes despite you not using any power. That's not supposed to happen, but I can't think of what

*should*happen.- fr0stbyte124
- Developer
**Posts:**727**Joined:**Fri Dec 07, 2012 3:39 am**Affiliation:**Aye-Aye

### Re: Orbits

I don't think this is going to work after all. For one thing, you might have ships at the same orbital distance flying in opposite directions. Their relative velocity is going to depend on the radius of their orbit, rather than any local system. The local velocities only work if everyone is orbiting in the same path, which is no good.