Question

Using python3 pls Problem 1: Write a Python function that uses spherical polar coordinates to det...

using python3 pls

Problem 1: Write a Python function that uses spherical polar coordinates to determine the distance between any two points on the earth's surface. The function will take as input two points, given in spherical polar coordinates, i.e. longitude and latitude. Assume your points are on the earth's surface, and that the earth is a sphere of radius 6378km

0 0
Add a comment Improve this question Transcribed image text
Answer #1


"""
  Python 3
  Program to find distance between two earth coordinates
"""

from math import radians, sin, cos, acos

print("Input coordinates of two points:")
startLat = radians(float(input("Starting latitude: ")))
startLon = radians(float(input("Starting longitude: ")))
endLat = radians(float(input("Ending latitude: ")))
endLon = radians(float(input("Ending longitude: ")))

dist = 6378 * acos(sin(startLat)*sin(endLat) + cos(startLat)*cos(endLat)*cos(startLon - endLon))
print("The distance is %.2fkm." % dist)

# Code ends here
Add a comment
Know the answer?
Add Answer to:
Using python3 pls Problem 1: Write a Python function that uses spherical polar coordinates to det...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C programming, code the following function: Write the function Location() that takes in two pairs...

    In C programming, code the following function: Write the function Location() that takes in two pairs of DEGREE (latitude, longitude) coordinates and returns the great-circle-distance between the points on the surface of the Earth, which is calculated using the formula: d = R acos[ cos(latA)cos(latB)cos(lonB-lonA) + sin(latA)sin(latB) ] where (latA,lonA) and (latB,lonB) are the RADIAN coordinates for the two points, R = 6368 km is the radius of the Earth (provided in the template as a global variable), d is...

  • BOX 5.1 The Polar Coordinate Basis Consider ordinary polar coordinates r and 0 (see figure 5.3)....

    BOX 5.1 The Polar Coordinate Basis Consider ordinary polar coordinates r and 0 (see figure 5.3). Note that the distance between two points with the same r coordinate but separated by an infinitesimal step do in 0 is r do (by the definition of angle). So there are (at least) two ways to define a basis vector for the direction (which we define to be tangent to the r = constant curve): (1) we could define a basis vector es...

  • Write the vector differential operator "DEL-V in Cartesian coordinates Cylindrical coordinates Spherical coordinates. 2. Show for...

    Write the vector differential operator "DEL-V in Cartesian coordinates Cylindrical coordinates Spherical coordinates. 2. Show for any "nice" scalar function (x,y,z), the Curl of the gradient of (x,y,z) is Zero.. VxVo = 0 Hint: assume the order of differentiation can be switched 3. Find the volume of a sphere of radius R by integrating the infinitesimal volume element of the sphere. 4. Write Maxwell's equations for the case of electro and magneto statics (the fields do not change in time)...

  • Program Description Write a program that calculates the distance between two places on Earth, based on...

    Program Description Write a program that calculates the distance between two places on Earth, based on their latitude and longitude. Prompt the user to enter the latitude and longitude of two places. The Earth’s mean radius is to be taken as 6371.01 km. Use user-defined variables with descriptive names wherever necessary. Following steps will have to be followed: Program must have header comments stating the author of the Program, date, and Program Description. Include the math.h header file Initialize a...

  • B.2. The surface Sc of an ice-cream cone can be parametrised in spherical polar coordinates (r,...

    B.2. The surface Sc of an ice-cream cone can be parametrised in spherical polar coordinates (r, 0, 0) by where θ0 is a constant (which you may assume is less than π/2) (a) Sketch the surface Sc (b) Using the expression show that the vector element of area on Sc is given by -T Sin where [41 (c) The vector field a(r) is given in Cartesian coordinates by Show that on Sc and hence that 4 2 (d) The curved...

  • Please answer all questions for UPVOTE LOCATION: Cleveland, Ohio DREAM LOCATION: Rome, Italy PRECALCULUS: VECTORS Directions: Suppose that you plan to take a trip to your dream destina...

    Please answer all questions for UPVOTE LOCATION: Cleveland, Ohio DREAM LOCATION: Rome, Italy PRECALCULUS: VECTORS Directions: Suppose that you plan to take a trip to your dream destination. You would like to know the shortest distance between your starting point and your destination. When calculating distances on a plane, you need only consider two dimensions because you are on a flat surface. However, when finding distances between two points on Earth, you must take into the account the curvature of...

  • 5. (a) 4points Figure 2 below shows the annual average radiation budget as a function of latitude...

    5. (a) 4points Figure 2 below shows the annual average radiation budget as a function of latitude. Estimate the latitude Lc where the net radiation crosses over from positive to negative in the Northern Hemisphere. Also estimate the value of the net radiation at the North Pole. Use the two pieces of information to find the equation of a straight line that approximately describes the net radiation (in WIm2) as a function of latitude L between 10 N and the...

  • Only need help with (d) = 0 ( [this point is away from 0] A conducting...

    Only need help with (d) = 0 ( [this point is away from 0] A conducting sphere of radius a is hollow and grounded (V = 0). A particle of charge q is a placed inside at a distance b from the center. We wish to find the potential anywhere inside the sphere. This problem can be solved with the image charge method. The image charge d' should be placed a distance b = from the center, so that the...

  • Problem 4 A uniform solid spherical ball of mass M and radius R rests on a horizontal surface. Assume a constant coeffi...

    Problem 4 A uniform solid spherical ball of mass M and radius R rests on a horizontal surface. Assume a constant coefficient of friction (this means that the frictional force is equal to the normal force multiplied by u). The acceleration due to gravity is g. At time t 0, the bal is struck impulsively on center, causing it to go instantaneously from rest to initial rotation horizontal speed vo with a no (a) Find the horizontal speed, and the...

  • 1(a)    Write a python program using a function name slope(x1, y1, x2, y2) that returns...

    1(a)    Write a python program using a function name slope(x1, y1, x2, y2) that returns the slope of the line through the points (x1, y1) and (x2, y2). 1(b) For problem 1(a), write a python program using a function name Euclidean_dist(x1, y1, x2, y2) which will calculate and return the Euclidean distance between the points (x1, y1) and (x2, y2).

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT