天天看点

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的都是多出来的,求解啊