⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calculate.cpp

📁 像片外方位元素计算程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
file.WriteString(a);
  a.Format("dX[%d]=%lf,      dY[%d]=%lf\n",i+1,dX[i],i+1,dY[i]);
  file.WriteString(a);
}
 a.Format("%s\n","======================================================");
 file.WriteString(a);
a.Format("%s\n","改正后的像点坐标:");
file.WriteString(a);
================================================================*/

  file.Close();
  

}

BOOL CCalculate::OnShowwindow() 
{
	// TODO: Add your control notification handler code here
/*
if(m_e)
{
AfxGetApp()->m_pMainWnd->MessageBox("已经输出数据到窗口了!","提示",MB_OK);
return FALSE;
}*/
	CReadWrite m_p;
	CListBox *m_pList1=(CListBox *)GetDlgItem(IDC_LIST1);
	CListBox *m_pList2=(CListBox *)GetDlgItem(IDC_LIST2);
	CString a,b;
	for(int i=0;i<6;i++){
		m_pList1->DeleteString(0);}
   //m_pList1->DeleteString(0);


	a.Format("dXs=%5.12lf",V[0]);
    m_pList1->InsertString(0,a);
	a.Format("dYs=%5.12lf",V[1]);
	m_pList1->InsertString(1,a);
	a.Format("dZs=%5.12lf",V[2]);
	m_pList1->InsertString(2,a);
	
	a.Format("dQ=%5.12lf",V[3]);
	m_pList1->InsertString(3,a);
	a.Format("dW=%5.12lf",V[4]);
	m_pList1->InsertString(4,a);
	
   a.Format("dK=%5.12lf",V[5]);
	m_pList1->InsertString(5,a);

/*==================================================================//预留区域
CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
m_p.Read1();
dX=(double*)malloc(sizeof(double)*m_p.m_pInDataHead.ControlNum);
dY=(double*)malloc(sizeof(double)*m_p.m_pInDataHead.ControlNum);
 
for(int i=0;i<pMain->m_ControlNum;i++){
Xp=m_p.m_pInData[i].Xp;
Yp=m_p.m_pInData[i].Yp;
Zp=m_p.m_pInData[i].Zp;
Xs=m_p.m_pInDataHead.Xs;
Ys=m_p.m_pInDataHead.Ys;
Zs=m_p.m_pInDataHead.Zs;	
f=m_p.m_pInDataHead.f;
x=m_p.m_pInData[i].x;
y=m_p.m_pInData[i].y;
dX[i]=f/(Zp-Zs)*V[0]+0*V[1]+x/(Zp-Zs)*V[2]+((Xp-Xs)*x-(Zp-Zs)*f)/(Zp-Zs)*V[3]+(Yp-Ys)*x/(Zp-Zs)*V[4]-(Yp-Ys)*f/(Zp-Zs)*V[5];
dY[i]=0*V[0]+f/(Zp-Zs)*V[1]+y/(Zp-Zs)*V[2]+((Xp-Xs)*y)/(Zp-Zs)*V[3]+((Yp-Ys)*y-(Zp-Zs)*f)/(Zp-Zs)*V[4]-(Xp-Xs)*f/(Zp-Zs)*V[5];
a.Format("dX[%d]=%lf\n",i+1,dX[i]);
b.Format("dY[%d]=%lf\n",i+1,dY[i]);
 m_pList2->AddString(a);
 m_pList2->AddString(b);

}
============================================*/
m_e=true;
return TRUE;
}

BOOL CCalculate::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CListBox *m_pList1=(CListBox *)GetDlgItem(IDC_LIST1);
	CListBox *m_pList2=(CListBox *)GetDlgItem(IDC_LIST2);
    m_pList2->ShowScrollBar(2);
	CButton *m_pB1=(CButton *)GetDlgItem(IDC_SHOWWINDOW);
		CButton *m_pB2=(CButton *)GetDlgItem(ID_OUTPUTDATA);
  m_pB1->EnableWindow(false);
   m_pB2->EnableWindow(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CCalculate::OnDialogCancel() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}

void CCalculate::OnButton2() 
{A=(double **)malloc(sizeof(double)*4);
Naa=(double **)malloc(sizeof(double)*4);

for(int jj=0;jj<4;jj++){
A[jj]=(double*)malloc(sizeof(double)*6);
Naa[jj]=(double *)malloc(sizeof(double)*4);
}
W=(double*)malloc(sizeof(double)*4);

K=(double *)malloc(sizeof(double)*4);
for(int i=0;i<4;i++){
		for(int j=0;j<6;j++)
			A[i][j]=i+j+1;
}
W[0]=W[1]=W[2]=W[3]=100;
JZXC(A,4,6);

	
QJFCZ(Naa,K,W,2);

}

BOOL CCalculate::OnDialogShowxy() 
{
CReadWrite m_p;
CString a,b;

if (!m_p.Read())
return false;
	q=m_p.m_pInDataHead.q;//*Pai/180;
	w=m_p.m_pInDataHead.w;//*Pai/180;
	k=m_p.m_pInDataHead.k;//*Pai/180;
//==================================

    GZS[0][0]=cos(q)*cos(k)-sin(q)*sin(w)*sin(k);
	GZS[0][1]=-cos(q)*sin(k)-sin(q)*sin(w)*cos(k);
	GZS[0][2]=-sin(q)*cos(w);
	GZS[1][0]=-cos(w)*sin(k);
	GZS[1][1]=cos(w)*cos(k);
	GZS[1][2]=-sin(w);
	GZS[2][0]=sin(q)*cos(k)+cos(q)*sin(w)*sin(k);
	GZS[2][1]=-sin(q)*sin(k)+cos(q)*sin(w)*cos(k);
	GZS[2][2]=cos(q)*cos(w);
 
CListBox *m_pList2=(CListBox *)GetDlgItem(IDC_LIST2);
	for(int ii=0;ii<2;ii++){
		m_pList2->DeleteString(0);}
Xs=m_p.m_pInDataHead.Xs;
Ys=m_p.m_pInDataHead.Ys;
Zs=m_p.m_pInDataHead.Zs;
f=m_p.m_pInDataHead.f;
for(int i=0;i<m_p.m_pInDataHead.ControlNum;i++)
{
Xp=m_p.m_pInData[i].Xp;
Yp=m_p.m_pInData[i].Yp;
Zp=m_p.m_pInData[i].Zp;
double sss=GZS[0][2]*(Xp-Xs)+GZS[1][2]*(Yp-Ys)+GZS[2][2]*(Zp-Zs);
x=-f*(GZS[0][0]*(Xp-Xs)+GZS[1][0]*(Yp-Ys)+GZS[2][0]*(Zp-Zs))/(GZS[0][2]*(Xp-Xs)+GZS[1][2]*(Yp-Ys)+GZS[2][2]*(Zp-Zs));
y=-f*(GZS[0][1]*(Xp-Xs)+GZS[1][1]*(Yp-Ys)+GZS[2][1]*(Zp-Zs))/(GZS[0][2]*(Xp-Xs)+GZS[1][2]*(Yp-Ys)+GZS[2][2]*(Zp-Zs));
	a.Format("x[%d]=%5.12lf",i+1,x);
	m_pList2->InsertString(i,a);
   	b.Format("y[%d]=%5.12lf",i+1,y);
	m_pList2->InsertString(i+1,b);
	

}

return TRUE;

}



void CCalculate::OnDialogShowoutdata() 
{
ShellExecute(NULL,"open","outdata.txt",NULL,NULL,SW_SHOWNORMAL);
	
}

void CCalculate::OnDialogShowindata() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(NULL,"open","data.txt",NULL,NULL,SW_SHOWNORMAL);
}

void CCalculate::OnButton3() 
{
	// TODO: Add your control notification handler code here
	
}

//gauss全主元消去法

int CCalculate::gauss(double **a, double *b, int n)
{
 int *js,l,k,i,j,is,p,q;
 double d,t;
 js=(int *)malloc(n*sizeof(int));
 l=1;
 for(k=0;k<=n-2;k++)
 {
	 d=0.0;
	 for(i=k;i<=n-1;i++)

		 for(j=k;j<=n-1;j++)
		 {
			 t=fabs(a[i][j]);
		 if(t>d)
		 {
			 d=t;js[k]=j;is=i;
		 }
		 }
    if(d+1.0==1.0) l=0;
	else
	{
		if(js[k]!=k)
			for(i=0;i<=n-1;i++)
			{
				t=a[i][k];
				a[i][k]=a[i][js[k]];
				a[i][js[k]]=t;
			}
    if(is!=k)
	{
		for(j=k;j<=n-1;j++)
		{
			p=k*n+j;q=is*n+j;
			t=a[k][j];
			a[k][j]=a[is][j];
			a[is][j]=t;
		}
    t=b[k];b[k]=b[is];b[is]=t;
	     }
	}
	if(l==0)
	{
		free(js);printf("fail\n");
		return(0);
	}
	d=a[k][k];
	for(j=k+1;j<=n-1;j++)
	{
		p=k*n+j;a[k][j]=a[k][j]/d;
	}
	b[k]=b[k]/d;
	for(i=k+1;i<=n-1;i++)
	{
		for(j=k+1;j<=n-1;j++)
		{
			p=i*n+j;
			a[i][j]=a[i][j]-a[i][k]*a[k][j];
		}
		b[i]=b[i]-a[i][k]*b[k];
	}
	 }
  d=a[n-1][n-1];
  if(fabs(d)+1.0==1.0)
  {
	  free(js);printf("fail\n");
	  return(0);
  }
  b[n-1]=b[n-1]/d;
  for(i=n-2;i>=0;i--)
  {
	  t=0.0;
	  for(j=i+1;j<=n-1;j++)
		  t=t+a[i][j]*b[j];
	  b[i]=b[i]-t;
  }
  js[n-1]=n-1;
  for(k=n-1;k>=0;k--)
	  if(js[k]!=k)
	  {
		  t=b[k];
	 b[k]=b[js[k]];
	 b[js[k]]=t;
	  }
	  free(js);
return(1);

}

int CCalculate::invMatrixGJ(double **a, int n)
{
	int *is,*js,i,j,k,l,u,v;
	double d,p;
	is=(int *)malloc(n*sizeof(int));
	js=(int *)malloc(n*sizeof(int));
	for(k=0;k<=n-1;k++)
	{
		d=0.0;
		for(i=k;i<=n-1;i++)
		for(j=k;j<=n-1;j++)
		{
			l=i*n+j;p=fabs(a[i][j]);
			if(p>d)
			{d=p;is[k]=i;js[k]=j;}
		}
    if(d+1.0==1.0)
	{
		free(is);free(js);printf("error not inv\n");
		return (0);
	}
	if(is[k]!=k)
		for(j=0;j<=n-1;j++)
		{
			u=k*n+j;v=is[k]*n+j;
			p=a[k][j];a[k][j]=a[is[k]][j];a[is[k]][j]=p;
		}
   
		if(js[k]!=k)
		  for(i=0;i<=n-1;i++)
		  {
			  u=i*n+k;v=i*n+js[k];
			  p=a[i][k];a[i][k]=a[i][js[k]];a[i][js[k]]=p;
		  }
   l=k*n+k;
   a[k][k]=1.0/a[k][k];
   for(j=0;j<=n-1;j++)
	   if(j!=k)
	   {
		   u=k*n+j;a[k][j]=a[k][j]*a[k][k];
	   }
    for(i=0;i<=n-1;i++)
		if(i!=k)
      for(j=0;j<=n-1;j++)
		  if(j!=k)
		  {
			  u=i*n+j;
			  a[i][j]=a[i][j]-a[i][k]*a[k][j];
		  }
     for(i=0;i<=n-1;i++)
		 if(i!=k)
		 {
			 u=i*n+k;a[i][k]=-a[i][k]*a[k][k];
		 }
    }
  for(k=n-1;k>=0;k--)
  {
	  if(js[k]!=k)
		  for(j=0;j<=n-1;j++)
		  {
			  u=k*n+j;v=js[k]*n+j;
			  p=a[k][j];a[k][j]=a[js[k]][j];a[js[k]][j]=p;
		  }
  if(is[k]!=k)
	  for(i=0;i<=n-1;i++)
	  {
		  u=i*n+k;v=i*n+is[k];
		  p=a[i][k];a[i][k]=a[i][is[k]];a[i][is[k]]=p;
	  }
  }
	  free(is);free(js);
		return (1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -