Hot answers tagged orbit
5
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.
...
4
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 ...
3
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 ...
2
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 ...
2
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 ...
2
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 ...
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.
1
That's not so bad if you know the position of A and B at all times. Example:
A is at the origin.
B is traveling around the origin at a distance of 1. (ie, it's orbit is the unit circle)
Let Y be the object leaving A.
Let the speed of B be such that every second B crosses an axis. So the period of B is 4 seconds. Therefore the position of B at any given ...
Only top voted, non community-wiki answers of a minimum length are eligible