I'm trying to find a nice algorithm to trace a sky route between 2 points of a planet.
Here is where I am : https://dl.dropboxusercontent.com/u/17657227/migrationGlobe/index.html
(or here http://xseignard.github.io/migrationGlobe/)
I tried Cubic (red line) and Quadratic (white one) bezier curves, but as you can see, results are bad!
The line is supposed to go from France (Nantes) to Australia (Canberra), and we see the line passing through the globe.
You can also see control points for each bezier cuve materialized by the squares.
Do you know what could be a good algorithm to create a nice sky route?
Something like this: http://www.senchalabs.org/philogl/PhiloGL/examples/worldFlights/
i.e flatter lines and not crossing the globe.
Thanks!
It looks like you have things basically correct. I'd recommend that you use cubic Bezier curves. Let's start with this picture:
I assume you know the start point $\mathbf{P}_0$ and the end point $\mathbf{P}_1$ of the flight, and you know the starting and ending tangent lines, too. We need to place the Bezier control points $\mathbf{P}_a$ and $\mathbf{P}_b$ on these tangent lines. The only question is how far along the tangent lines we should go.
So, first decide where you want to place the mid-point $\mathbf{M}$ of the flight. I suppose $\mathbf{M}$ will be at some height above the surface of the earth. Then, with a little geometry, you can figure out the points $\mathbf{P}_r$ and $\mathbf{P}_s$ and the distance $d$. Then place the Bezier points on the end tangent lines so that $\|\mathbf{P}_a - \mathbf{P}_0\| = \tfrac43 d$ and $\|\mathbf{P}_b - \mathbf{P}_1\| = \tfrac43 d$. This will give you a Bezier curve that passes through the point $\mathbf{M}$.