# Tag Info

7

The bug is in the fall function. We have delta: a vector from the well to the ship force: the magnitude of the gravity between these two bodies. |force| is G * m1 * m2 / r^2 but |delta| is already r! so you are actually accelerating too fast. You need to divide by r again (basically normalizing the delta vector) before calling accelerate. accelerate(...

6

Make the moon a child of the planet object, and the planet a child of the star. Now, if the moon wasn't orbiting, it will stay with the planet in its orbit. You can easily rotate an arbitrary point around another arbitrary point with the following: public static Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Quaternion angle) { return ...

5

I calculated true anomaly as function of time, for planetary motion , in c# , in this way: Compute mean anomaly (time: current time , G: newton grav.connstant, M: planet mass or the sum of the two orbiting objects , a: semi major axis) //M = nt double n = Math.Sqrt((G * (M)) / (a * a * a)); double Mt = n * time; Compute ...

5

Intuition Here's one way: Let's rotate your diagram. Now the rocket is a cannonball! Physics It has a fixed acceleration "downwards" i.e. perpendicular to the vector from its firing location to its target. I drew it above as a dashed green line. Let's call that the reference horizon. (Note that this reference horizon is constant! The rocket was fired ...

5

It looks like the problem is that the missile is simply pointing itself at the target without regard for it's current velocity. Assign your missile a maximum angle by which the thrust can deviate from the line of motion. At each guidance iteration you calculate it's velocity perpendicular to the target. Figure out how much it must tip it's engine in order ...

4

What you're looking for is an ArcBall Camera. I've got a full snippet over here http://roy-t.nl/index.php/2010/02/21/xna-simple-arcballcamera/ but just to explain the general idea: You set a look-at point in space which you want to orbit. Then you create a vector from that point by rotate around it using the Pitch Yaw and Roll. You then lengthen the vector ...

4

It may not be the elegant solution you are after, but I've found that if I slow the missile, if it's going to miss, as it approaches the target, it effectively tracks and turns quicker and can hit the target. You could increase the turn rate of the missile as it gets closer, rather than reducing the speed, but this might give players a 'wow I'm sure that was ...

4

Use a logarithmic scale where drawnRadius = log(actualRadius). You then end up with a spacing like this which shows all the planets quite neatly separated: (this representation appears to be using logarithm to base 4) When you want to apply this to your planetary simulation, you first need to convert the carthesian coordinates (x, y) of each planet to ...

4

Note that even with the math bug(s) fixed, you're using Euler integration (i.e. velocity += delta and presumably position += velocity), so you're probably going to get some odd effects like rotation of the orbital ellipse over time, and perhaps the ellipse getting larger/smaller since Euler integration isn't guaranteed to conserve energy. You might want to ...

3

Assuming realistic Newtonian gravity (i.e. that the gravitational force between two bodies is inversely proportional to the square of their distance), and that the planets don't interact gravitationally with each other, but only with the sun, then the planets will always follow Kepler orbits (which, if closed, will always be elliptical). Conversely, if the ...

3

The first thing to do when you want to model space as it is is to understand Newtons laws of motion. An object keeps moving with a constant speed and direction unless a force acts on it. That means you need to get away from the methodology of moving an object by changing its position. Give an object a speed in x- and y-direction and then change its ...

2

By the look of things you should be able to apply this script to your moon and simply point to the planetary object you want it to orbit. However given the fact that your planet is moving, it looks like your moons will probably be playing catch up to the planets orbiting the sun. You should be able to fix this with a simple hierarchy change. - Sun ...

2

First generate a random 3D rotation matrix. Then for each frame compute a simple, boring rotation vector around the center (e.g x = r*cos(k*t), y = r*sin(k*t), z = 0), multiply it by the rotation matrix, add it to the center of the sphere, and you have a random orbit.

2

I would suggest creating an arc-ball camera. This is a camera that can orbit around the point-of-interest and change its distance from the point-of-interest (basically zooming in and out). By simpling changing the location of the point-of-interest you get panning for free ;). Have a look at this code snippet: http://roy-t.nl/index.php/2010/02/21/xna-simple-...

2

From what it seems, you are approaching your problem backwards :) The first problem you are facing is that you try to give an physics object, that is kicked by something else, a hard-coded trajectory, which means exterior influences (the kick) will not make it move. Instead, you could implement the gravity simulation from the second problem first. Then, if ...

2

You can implement a global variable that flips between each mode. You can reduce the amount of frames that are being rendered per second. So for example, for a manager object you can have this code in the create event: //Slow mode if(global.gameplayMode == 0) { room_speed = 30; } //Fast mode else if(global.gameplayMode == 1) { room_speed = 60; } ...

2

When the user presses the "orbit" button, store the vector between the ship and the planet. On every update, change the vector's angle leaving magnitude the same and then update the ships position by adding the planets position and the vector pointing at the ships new position. This will create the effect of the ship moving in a uniform circle around the ...

2

I use Game Maker 8.1 all the time, and I've done orbital sims in them too. More good news: Game Maker has a built-in function that does vector addition for you: motion_add(direction, acceleration) this will automatically change an object's hspeed and vspeed with the correct vector addition. Remember that Game Maker treats 0 degree angle pointing right, 90 ...

1

A much simpler approach to this would be to use vector math. I'm assuming you're trying to get the closest point to the mouse on the outer sphere. All you really have to do is get the vector from your center point to the mouse point, normalize, and then multiply by the radius of your sphere. screenpos = Camera.main.ScreenToWorldPoint (Input.mousePosition); ...

1

Maybe the easiest approach would be to just create checkpoints. Seperate the space around the sun into, for example, 4 sectors: -x, -y +x, -y +x, +y -y, +y Knowing the relative coordinates of the planet you can easily compute in which sector it currently is. You can assume the planet to have revoluted the sun once it has visited all four sectors.

1

The parametric equations of circular motion are: circle_x = radius * cos(rate * time + phase) + center_x circle_y = radius * sin(rate * time + phase) + center_y So all you really need to do is rotate this into an arbitrary 3D plane. You can do this by providing two orthonormal basis vectors (meaning they are perpendicular and have a length of 1) u and v, ...

1

I suggest using Cartesain Orbit Elements , with rk4 in real time simulation. Switch to kepler Orbit Elements (orbit as a function of time) when you augment timestep. Try this answer of mine as reference Another example schenario: when your orbital body is subject to only gravity force , use kepler Orbit Elements , whe you turn on body engine (to add/...

1

Have you tried wikipedia's article on (4th-order) Symplectic Integration? It's got a handful of further links for you too.

1

You need to clamp the vertical rotation. I don't know off the top of my head the simplest way to adjust that code, but it'll just involve changing a couple lines around the transform.RotateAround() stuff, to use Mathf.Clamp() for the angle around the x-axis. I think you just need to put in y = Mathf.Clamp(y, -180, 180); right after incrementing y. This way ...

1

The key is to analyze how an actual camera would work. If you're pointing it toward, say, a wall in front of you, then you point it toward the ceiling, and then keep turning it "up" you will find that the ground will actually start to come into view from the top. It seems odd at first - but the actual camera configuration you have is already "correct" IMO. ...

1

If the players will never know the difference, then don't worry about mass or radius. For the oribiting planet store - the distance to the center planet (radius of rotation) - current position in degrees - orbit-speed (degrees per game tick) For each game tick - change the position by adding the speed - calculate the new position (using Cos and Sin) ...

1

If players have no effect over the orbit (such as moving planets) then the best option would simply be to define paths for the planet to travel along (using bezier curves etc). It's stable and simple. You would never be able to affect the movement in game (unless you went to the trouble of altering the defined path) and may open up unrealistic possibilities (...

1

Have you tried changing the field of view component of your projection matrix? Your current field of view is set to MathHelper.PiOver4 if swap this out for a modifiable value you should be able to zoom in and out.

1

I know exactly what's going on and it's a tricky one:) In time, since one orbits after the other (the update functions do not happen at the same time), their distance increases or decreases little by little. Right when the planet orbits a bit, you want your moon to do exactly the same motion so that their distance does not change. Otherwise you'll make an ...

1

I'd construct a line from the centre of the planet to the ship, and also calculate a point which is the ship's position + ship's velocity. From there you can use a standard test to find out which side of the line the point is on, which tells you if it should orbit clockwise or anticlockwise.

Only top voted, non community-wiki answers of a minimum length are eligible