I am working on a project which requires a missile to travel around a sphere (a planet).
I am using a parabolic trajectory found with the equation:
f(x) = (-h / l2) * (x - l)2 + h + r where h is parabola height, l is x position of the apex (this is found from the target position as a ratio of the arc length which is known), and r is the radius of the planet the missile is on.
I then put the resulting f(x) values into a float-array. I now want to convert that array into Vector3 points as the missile flies. This is easy enough assuming I can find the shortest direction from the original point to the target point.
Like I say, I already know the shortest arc length d = sin-1(chord / 2r) * 2r but that does not tell me the shortest direction around the sphere.
So, how do I find the shortest direction around a sphere from the missile origin point to a target? Remember that the missile will be firing almost perpendicular to the tangent of the sphere’s surface as per the shape of a parabola.
So, this is like firing nuclear missiles between Russia and us, and some go over the artic, since that’s closer, but some might be shorter going over the Atlantic?
If you take the normals of the launch point and target, then the Cross-Product will give you the rotation axis between them. (Untested starting here) Since you’re plotting in (x,y), that’s the local z-axis as they fly. So, use Quaternion.FromToRotation(new Vector3(0,0,1), CrossProd) to map your (x,y) points into that space.
So, did I understand it well, that f(x) gives you points, which are all on a constant r around the planet center. And now you want to find out the shortest way from start to end point while maintaining a constant radius??
If yes, the problem sounds trivial to me. You can compute the vectors from starting point to the planet center and from the end point to the planet center. If you then look at the angle between the two you can see, if it is bigger or smaller than 180°.
This decides the direction, in which you traverse the points from f(x). Did I miss something?