天天看點

c語言求未知坐标,求助,有關坐标計算的

該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓

#include "stdafx.h"

#include

#include

#include

#include

#define PI 3.14159265358979

using namespace std;

void main()

{

double point[100][3];

char name[100][1];

int i;

FILE *fp=fopen("D:\\作業\\大地坐标.txt","r");

if(fp!=NULL)

for(i=0;fscanf(fp,"%c%lf%lf%lf",&name[i][0],&point[i][0],&point[i][1],&point[i][2])!=EOF;i++);

fclose(fp);

double a=6378137.00,b,e,N;

double X[100],Y[100],Z[100];

char A[100];

int j;

e=sqrt(0.00669437999013);

b=e*e;

FILE *nw;

nw=fopen("D:\\作業\\大地坐标轉換.txt","w");

fprintf(nw,"點号\t\tX\t\tY\t\tZ\n");

for (j=0;j<=i;j++)

{

N=a/(sqrt(1-b*(sin(point[j][0]*PI/180))*(sin(point[j][0]*PI/180))));

A[j]=name[j][0];

X[j]=(N+point[j][2])*cos(point[j][0]*PI/180)*cos(point[j][1]*PI/180);

Y[j]=(N+point[j][2])*cos(point[j][0]*PI/180)*sin(point[j][1]*PI/180);

Z[j]=((1-b)*N+point[j][2])*sin(point[j][0]*PI/180);

fprintf(nw,"%c\t%lf\t%lf\t%lf\n",A[j],X[j],Y[j],Z[j]);

}

fclose(nw);

這是我的程式,為什麼産生的結果裡面卻多出來好多數

點号 X Y Z

A -2235714.338406 4583893.696709 3817435.287400 -23654007456993444000000000000000000000000000000000000000000000.000000 -40371947455848931000000000000000000000000000000000000000000000.000000 -79861624985773307000000000000000000000000000000000000000000000.000000

B -2202842.424937 4598907.632492 3818461.269224 -23654007456993444000000000000000000000000000000000000000000000.000000 -40371947455848931000000000000000000000000000000000000000000000.000000 -79861624985773307000000000000000000000000000000000000000000000.000000

C -2247709.318822 4607966.477709 3781475.984384 -23654007456993444000000000000000000000000000000000000000000000.000000 -40371947455848931000000000000000000000000000000000000000000000.000000 -79861624985773307000000000000000000000000000000000000000000000.000000

?-23654007456993444000000000000000000000000000000000000000000000.000000 -40371947455848931000000000000000000000000000000000000000000000.000000 -79861624985773307000000000000000000000000000000000000000000000.000000

每一行帶有好多0的都是多出來的,求解啊