Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The code is below advice somthing innovate or try to remove error. The project i

ID: 3538599 • Letter: T

Question

The code is below advice somthing innovate or try to remove error. The project is under .net.


private static double rad2deg = 180.0 / Math.PI;


private bool Transform(double WGlat, double WGlon, double height)

{

double radWGlat = WGlat * deg2rad;

double radWGlon = WGlon * deg2rad;

double a = 6378137;

double e = 0.00669438037928458;

double h = height;   

double a2 = 6377563.396;   

double e2 = 0.0066705397616;   

double xp = -446.448;

double yp = 125.157;

double zp = -542.06;

double xr = -0.1502;

double yr = -0.247;

double zr = -0.8421;

double s = 20.4894;

double sf = s * 0.000001;

double v = a / (Math.Sqrt(1 - (e * (Math.Sin(radWGlat) * Math.Sin(radWGlat))));

double x = (v + h) * Math.Cos(radWGlat) * Math.Cos(radWGlon);

double y = (v + h) * Math.Cos(radWGlat) * Math.Sin(radWGlon);

double z = ((1 - e) * v + h) * Math.Sin(radWGlat);

double xrot = (xr / 3600) * deg2rad;

double yrot = (yr / 3600) * deg2rad;

double zrot = (zr / 3600) * deg2rad;

double hx = x + (x * sf) - (y * zrot) + (z * yrot) + xp;

double hy = (x * zrot) + y + (y * sf) - (z * xrot) + yp;

double hz = (-1 * x * yrot) + (y * xrot) + z + (z * sf) + zp

double newLon = Math.Atan(hy / hx);

double p = Math.Sqrt((hx * hx) + (hy * hy));

double newLat = Math.Atan(hz / (p * (1 - e2)));

v = a2 / (Math.Sqrt(1 - e2 * (Math.Sin(newLat) * Math.Sin(newLat)));

double errvalue = 1.0;

double lat0 = 0;

while (errvalue > 0.001)

{

lat0 = Math.Atan((hz + e2 * v * Math.Sin(newLat)) / p);

errvalue = Math.Abs(lat0 - newLat);

newLat = lat0;

}

return true;

}

Explanation / Answer

private static double deg2rad = Math.PI / 180;

private static double rad2deg = 180.0 / Math.PI;


private bool Transform(double WGlat, double WGlon, double height)

{

double radWGlat = WGlat * deg2rad;

double radWGlon = WGlon * deg2rad;

double a = 6378137;

double e = 0.00669438037928458;

double h = height;   

double a2 = 6377563.396;   

double e2 = 0.0066705397616;   

double xp = -446.448;

double yp = 125.157;

double zp = -542.06;

double xr = -0.1502;

double yr = -0.247;

double zr = -0.8421;

double s = 20.4894;

double sf = s * 0.000001;

double v = a / (Math.Sqrt(1 - (e * (Math.Sin(radWGlat) * Math.Sin(radWGlat)))));

double x = (v + h) * Math.Cos(radWGlat) * Math.Cos(radWGlon);

double y = (v + h) * Math.Cos(radWGlat) * Math.Sin(radWGlon);

double z = ((1 - e) * v + h) * Math.Sin(radWGlat);

double xrot = (xr / 3600) * deg2rad;

double yrot = (yr / 3600) * deg2rad;

double zrot = (zr / 3600) * deg2rad;

double hx = x + (x * sf) - (y * zrot) + (z * yrot) + xp;

double hy = (x * zrot) + y + (y * sf) - (z * xrot) + yp;

double hz = (-1 * x * yrot) + (y * xrot) + z + (z * sf) + zp;

double newLon = Math.Atan(hy / hx);

double p = Math.Sqrt((hx * hx) + (hy * hy));

double newLat = Math.Atan(hz / (p * (1 - e2)));

v = a2 / (Math.Sqrt(1 - e2 * (Math.Sin(newLat) * Math.Sin(newLat))));

double errvalue = 1.0;

double lat0 = 0;

while (errvalue > 0.001)

{

lat0 = Math.Atan((hz + e2 * v * Math.Sin(newLat)) / p);

errvalue = Math.Abs(lat0 - newLat);

newLat = lat0;

}

newLat = newLat * rad2deg; // *THIS IS A FUNCTION WHICH IS MISSING*//

newLon = newLon * rad2deg; // *THIS IS A FUNCTION WHICH IS MISSING*//

LLtoNE(newLat, newLon); // *THIS IS A FUNCTION WHICH IS MISSING*//

return true;

}