English 中文(简体)
Find 2 points on a 3d object and get their distance
原标题:

Ok. So I guess thing would to be envision new york city and beijing highlighted on google earth...

I m trying to figure out how to map points onto a 3d primitive object (a sphere), get their distance via any direction by the circumference, and their distance by diameter. The points are going to be latitude and longitude coordinates.

Right now, this is what i m trying to use to map the coordinates (a code agnostic version):

  x1 =  radius * cos(long1) * cos(lat1);
  y1 =  radius * sin(long1) * cos(lat1);
  z1 =  radius * sin(lat1);

but i m almost sure its wrong. How could I get each points position and calculate their distances straight across the sphere s diameter and also their distance going around the circumference of the sphere?

Thanks.

最佳回答

You re actually pretty close. To get the straight line distance, you simply need to do:

sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)

For the distance around the great circle, remember that it is pidiamangle. The dot product of the vectors from the center of the earth to the two points is the cosine of the angle. So, you get:

pidiamacos((x1*x2 + y1*y2 + z1*z1)/diam^2)

of course there s a 2nd distance if you go the other way around the earth, but for that you just need 2*pi - acos(...).

问题回答

暂无回答




相关问题
Maths in LaTex table of contents

I am trying to add a table of contents for my LaTex document. The issue I am having is that this line: subsubsection{The expectation of (X^2)} Causes an error in the file that contains the ...

Math Overflow -- Handling Large Numbers

I am having a problem handling large numbers. I need to calculate the log of a very large number. The number is the product of a series of numbers. For example: log(2x3x66x435x444) though my actual ...

Radial plotting algorithm

I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...

Subsequent weighted algorithm for comparison

I have two rows of numbers ... 1) 2 2 1 0 0 1 2) 1.5 1 0 .5 1 2 Each column is compared to each other. Lower values are better. For example Column 1, row 2 s value (1.5) is more ...

热门标签