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 the
distance between the points (in km), and acos() is the inverse
cosine function. Note that the input (latitude, longitude)
coordinates are in DEGREES, so you will need to
convert from DEGREES to RADIANS
in order to use the formula. As an example, a quick search for
chicago latitude longitude and
milwaukee latitude longitude should give
you the coordinates for Chicago and Milwaukee. Then, one more
search for Chicago to Milwaukee distance as the crow
flies will give you the approximate distance (~131
km) that should be returned from your function when the arguments
are the coordinates for the two cities.
// C program to calculate Distance Between Two Points on
Earth
//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
#include <stdio.h>
// Utility function for converting degrees to radians
long double toRadians(long double degee)
{
long double one_deg = (M_PI) / 180;
return (one_deg * degree);
}
long double location(long double latA, long double long1, long
double latB, long double long2)
{
// Convert the latitudes and longitudes from degree to
radians.
latA = toRadians(latA);
long1 = toRadians(long1);
latB = toRadians(latB);
long2 = toRadians(long2);
long double dlong = long2 - long1;
long double dlat = latB - latA;
long double R = 6368;
d = R* acos*[ cos(latA)*cos(latB)*cos(lonB-lonA) +
sin(latA)*sin(latB) ]
// Calculate the result
return d;
}
int main()
{
long double latA;
long double long1 ;
long double latB ;
long double long2 ;
printf("ENTER THE LATITUDE AND LONGITUDE");
scanf("%d%d%d%d%d",&latA, &long1,&latB,
&long2);
location(long double latA, long double long1, long double latB,
long double long2) ;
}
In C programming, code the following function: Write the function Location() that takes in two pairs...
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
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...
The following C++ code contains an incomplete program that should be able to calculate the distance between a series of geocoded locations. Two parts of the program need to be completed: 1. The portion of the main() function that calculates the distances between each of the hard-coded 5 locations, and stores it in a two-dimensional array declared as distances. 2. A portion of the calculateDistanceBetweenLocations(l1, l2) function; omitted code spaces are designed with a // TODO: comment. The code is properly...
I need this in c++ please Write a Map class that is composed of a Location class. Location class has three private variable string nameOfCity, double variables, latitude and longitude. It has a constructor to initialize these and also the usual getters. It has three functions: string toString() which prints :double getFlyingTime(Location l) which returns the flying time between this and location l. It uses the formula that time = distance/speed. speed = 673 miles/hour. No need to convert to...
1. in Matlab, write a user-defined function, with two input (r,theta) , θ expressed in degrees) and two output arguments (X,Y). The inputs are a location on a polar coordinates corresponding to Cartesian plane expressed in rectangular coordinates. The picture below describes the problem. X, Y rcos θ Some formula that you may need: x = r * cos (theta * pi/180); y r * sin(theta * pi/180); Test your code for r=7, theta=55° and present your results.
C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the Facility.cpp file and the other files are included in case they're needed for understanding. I was able to complete the mayday.cpp file but am stuck on Facility. The following link contains a tar file with the files provided by the professor. Thank you so much in advanced! http://web.cs.ucdavis.edu/~fgygi/ecs40/homework/hw4/ Closer.h: #ifndef CLOSER_H #define CLOSER_H #include <string> #include "gcdistance.h" struct Closer { const double latitude, longitude;...