math - Find 2 points on a 3d object and get their distance -
Okay so I think that New York City has to be imagined and Beijing needs to see Beijing highlighted on Google Earth ...
I am trying to figure out how to map points on a 3D primitive object (a field), distance from any direction through the perimeter, and from diameter Their distance points are going to be latitude and longitude coordinates.
Now, this is what I am trying to use to map coordinate (a code agnostic version):
x1 = radius * cos ( Long1) * cos (lat1); Y1 = radius * sin (tall 1) * cos (lat 1); Z1 = radius * sin (lat1);
But I'm sure this is wrong how can I get each point and their gap can be directly round the diameter of the hemisphere and their distance around the perimeter of the goal ?
Thank you. Class = "post-text" itemprop = "text">
You are really very close to get a straight line distance, all you need to do is:
sqrt ((x2- X1) ^ 2 + (y2-y1) ^ 2 + (z2-z1) ^ 2)
For the distance around the great circle, remember that it p diam Angle is the cosine of the product angle of the vector from the center of the earth to the two points. So, you receive:
PI diam acos ((x1 * x2 + y1 * y2 + z1 * z1) / diam ^ 2)
Of course if you go around the earth on the other side then there is another distance, but for this you need 2 * pi - acos (...).
Comments
Post a Comment