plotting a semi circular path given two end points

2019-07-02 18:54发布

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?

2条回答
放我归山
2楼-- · 2019-07-02 19:29
  1. sphere-like object

    you mean ellipsoid with Z as rotation axis and plane XY as equator? If yes use spherical coordinate system like P(a,b,h) a=<0,2PI>, b=<-PI,+PI>, h=<0,+inf> ... height above surface:

    r=(Re+h)*cos(b);
    x=r*cos(a);
    y=r*sin(a);
    z=(Rp+h)*sin(b);
    

    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 is 3.1415...
  2. curve path between 2 points

    now you have P0,P1 3D points. Convert them into spherical coordinates so you have:

    P0(a0,b0,h0)
    P1(a1,b1,h1)
    

    I assume h=0. Now just interpolate P(a,b,h) P0 to P1 by some parameter t=<0,1>

    a=a0+(a1-a0)*t
    b=b0+(b1-b0)*t
    h=h0+(h1-h0)*t
    

    this will create path on the surface. To make it above just add some curve to h like this:

    h=h0+(h1-h0)*t+H*cos(PI*t)
    

    Where H is max height above surface. You can add any curve type ... Now just do for loop where t goes from 0 to 1 by some step (0.01) and compute P. Convert it back to Cartesian coordinates and draw the line segment. Or just draw your moving object ...

查看更多
The star\"
3楼-- · 2019-07-02 19:32

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.

查看更多
登录 后发表回答