Code for Great Circle: Get Phi1 Theta1 to Phi2 Theta2 on Sphere

In summary, the conversation is about finding ready code for calculating the distance between two points on a sphere using the Great Circle formula. The language for the code could be anything similar to C, and the main purpose is to avoid making mistakes that have already been fixed. The conversation also mentions a potential solution found on Google, but the person is open to other options as well.
  • #1
makc
65
0
wonder if anyone have stumbled across ready code for http://mathworld.wolfram.com/GreatCircle.html" - i.e., the code to get from phi1 theta1 to phi2 theta2 on sphere.
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
"Code"? In what language?

All you should really need to do is just copy equation (5) from that page, it should work almost verbatim as code in almost any programming language, just remember that [tex]cos^{-1}[/tex] becomes for example "acos" in C.
 
  • #3
for starters, eq. 5 gives nothing but distance. what I need is deltas of phi and theta (ideally as a function of t = 0...1). the language could be anything that remotely looks like c (i.e. not lisp). the reason to ask for code is to avoid making bugs that were already made and fixed.

so far, closest to what I am looking for is http://www.google.com.ua/codesearch?q=basemap-0.9.4%2Flib%2Fmatplotlib%2Ftoolkits%2Fbasemap%2Fgreatcircle.py&hl=ru&btnG=%D0%9F%D0%BE%D0%B8%D1%81%D0%BA+%D0%BA%D0%BE%D0%B4%D0%B0 , but I'm open for other options :)
 
Last edited by a moderator:

1. What is the purpose of the "Code for Great Circle: Get Phi1 Theta1 to Phi2 Theta2 on Sphere"?

The purpose of this code is to calculate the shortest distance between two points on a sphere, which can be useful in a variety of applications such as navigation, astronomy, and geodesy.

2. How does the code calculate the great circle distance?

The code uses the Haversine formula, which takes into account the curvature of the Earth's surface, to calculate the great circle distance between two points on a sphere.

3. What are the inputs and outputs of the code?

The inputs of the code are the coordinates (latitude and longitude) of the starting point and the destination point. The outputs are the great circle distance between the two points and the initial and final bearings (directions) from the starting point to the destination point.

4. Can the code be used for any two points on Earth?

Yes, the code can be used for any two points on Earth, as long as the coordinates are entered in decimal degrees format.

5. How accurate is the calculated great circle distance?

The calculated great circle distance is accurate to within 0.5% of the actual distance, which is a reasonable level of accuracy for most applications. However, it should be noted that the Earth is not a perfect sphere, so the calculated distance may differ slightly from the actual distance in certain cases.

Similar threads

Replies
7
Views
3K
Replies
6
Views
650
  • Programming and Computer Science
Replies
17
Views
2K
  • Classical Physics
Replies
2
Views
4K
Replies
3
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
Replies
1
Views
3K
  • Introductory Physics Homework Help
Replies
4
Views
1K
  • Programming and Computer Science
Replies
9
Views
2K
  • STEM Academic Advising
Replies
11
Views
1K
Back
Top