1

我正在使用地理坐标(纬度、经度)。我有墙的每个角落的坐标。

我想知道左下角右侧 10 厘米的点的坐标。我不确定这是否可能。

谢谢。

4

1 回答 1

3

Simple method

Since latitude and longitude are a system of coordinates on a non-Euclidian surface (spherical 2-space), they are pretty awkward to work with directly.

I'd suggest the following. Convert your two coordinates to 3D Cartesian vectors:

z = R * sin(latitude);
Rcoslat = R * cos(latitude);
x = Rcoslat * cos(longitude);
y = Rcoslat * sin(longitude);

with R = 6378 km the (mean) radius of the Earth. Note that most trig functions in most computer languages take their argument in radians, so you'll have to multiply any degrees you have by pi/180 before taking their sin() or cos().

Doing this for both coordinates of a side of the wall gives you two vectors

v1 = (x1 y1 z1)
v2 = (x2 y2 z2)

The difference between these vectors will give you the proper direction to go in:

v3 = v1-v2  (if v1 is your leftmost coordinate)
v3 = v2-v1  (if v2 is your leftmost coordinate)

The length of v3 is the width of your wall. Extend it by 10cm to get a new vector:

L  = sqrt( v3x*v3x + v3y*v3y + v3z*v3z )  (width of the wall)
v4 = v3/L * (L+10cm) = v3 * (1 + 10cm/L)

Note that you'll have to do some unit juggling there, since if you take R in kilometers, L will be in kilometers, too.

Now that you have the new vector, you can convert it back to latitude/longitude:

hypotxy   = hypot( v4x, v4y)
latitude  = atan2( v4z, hypotxy )
longitude = atan2( v4y, v4x )

Where atan2 is the four-quadrant arctangent, and hypot(a,b) is just a fairly standard way to compute sqrt(a*a+b*b) with a greatly reduced risk of numerical over/underflow. Note again that the output of atan2 in most computer languages will be in radians, so if you want your latitude/longitude in degrees, you'll have to multiply the outcome by 180/pi.

Any more accurate method

The method above makes a few errors due to some simplifications that are hardly noticeable on small scales (like your ordinary everyday wall). But of your wall is actually the Great Wall of China, then you'll find that these errors become pretty unacceptable.

The errors made are due to these assumptions:

  1. Latitude and longitude are coordinates on a sphere. Usually, they're not. If they come from a GPS receiver of some quality, they describe coordinates on the reference ellipsoid of the Earth. The conversion between these coordinates and a Cartesian vector is slightly more involved.

  2. The difference vector v3 is just that, a vector. A vector is a straight line segment, while the actual line connecting the points v1 and v2 is slightly curved (because the Earth is not flat). Extending v3 to find v4 will therefore introduce an error. You'll actually have to extend the curved line. Again, this can be done simply (by assuming the Earth is a sphere again, and using cross and dot products), or more accurately (by extending the line on the Earth's reference ellipsoid).

These corrections are pretty specific and can get very long and very ugly, so I'll leave it at this. I think the "simple method" above suffices for your need anyway.

Nevertheless, if you ever need to do it with more accuracy: If you're smart, you'll use some existing Geo software library for it. If you're smarter, you'll look up all the formulas and relevant information and make the implementation yourself, discover that your implementation has errors and side effects, correct them and learn from this again :)

于 2012-09-21T08:53:46.047 回答