Assume a Spherical object like earth. Say I have two end points 3D, where I am currently and where I wanted to go. I want to construct a path in the atmosphere - some kind of a semi-circular path to interpolate from one point to another. a path on the earth like the one in http://workshop.chromeexperiments.com/projects/armsglobe/
The next position is computed based on current position. Has someone done the math for it before?
sphere-like object
you mean ellipsoid with
Z
as rotation axis and planeXY
as equator? If yes use spherical coordinate system likeP(a,b,h) a=<0,2PI>, b=<-PI,+PI>, h=<0,+inf>
... height above surface:Where:
Rp
is polar radius of ellipsoid (between center and pole on Z axis)Re
is equatorial radius of ellipsoid (circle on XY plane)PI
is3.1415
...curve path between 2 points
now you have
P0,P1
3D points. Convert them into spherical coordinates so you have:I assume
h=0
. Now just interpolateP(a,b,h)
P0 toP1
by some parametert=<0,1>
this will create path on the surface. To make it above just add some curve to
h
like this:Where
H
is max height above surface. You can add any curve type ... Now just dofor
loop wheret
goes from0
to1
by some step (0.01
) and computeP
. Convert it back to Cartesian coordinates and draw the line segment. Or just draw your moving object ...If you want the same exact thing as the link, you need to find or derive (I'm not inclined to do the calculus that'll probably be required to derive the formula it right now) a 3D trajectory formula that takes into account the curvature of the Earth. You'd probably be better of trying mathematics stack and have them derive the formula. Although, they might redirect you to a more physics oriented stack exchange, which might know the formula.
However, you could also simply cheat by creating an arc, but it probably won't look as good unless you are fairly careful in picking where the middle point of the arc will be.