测绘程序设计基础 实验4 CSU
实验4 类的创建
(大地四边形类设计)
(工具:VS2010)
一、 实验目的
• 掌握面向对象编程基本思想
• 掌握VC++.net中创建类
• 掌握建立和使用对象
• 掌握运算符号重载
• 理解类的继承和多态性
二、实验内容与要求
设计一个大地四边形类,注意大地四边形的基本属性,功能上只要求能够设置和返回已知点坐标、8个观测角度、待定点近似坐标计算以及闭合差的计算。
三、设计与实现:
3.1 设计思路:
3.2 界面设计及属性:
3.3主要代码:
3.3.1文件:<Support.h>
#pragma once
#include "Angle.h"
#include "math.h"
#include "matrix.h"
class Support
{
private:
Angle Angles[8];
Angle Results[8];
double x1;
double y1;
double x2;
double y2;
double x3;
double y3;
double x4;
double y4;
public:
Support(void);
~Support(void);
void ForeIntersecPos(double Xa,double Ya, double Xb,double Yb,
double Alfa,double Beta, double &Xp,double &Yp);
int SplitStringArray(CString str, char split, CStringArray& aStr);
//读取数据至数组
void read(CString strdate,Support &p);
//对数据进行处理
void out(CString &strResult,Support &p,double Sigma);
void pocess(CString strdate,CString &strResult);
//输出
};
3.3.2文件:<Support.cpp>
/***************************************************************************
* 文件名:<Support.cpp> *
* *
* 描述:大地四边形 *
* *
* 历史:**日期** **理由** **签名** *
* 2019年4月5日 代码格式修改 张 *
* *
* 外部过程: *
* *
/**************************************************************************/
/***************************************************************************
* 名字:void ForeIntersecPos *
* *
* 描述:前方交会函数,利用引用赋值 *
* *
* 历史:**日期** **理由** **签名** *
* 2019年4月5日 引用该函数 张 *
* 参数: 1.double Xa *
* 2.double Ya *
* 3.double Xb *
* 4.double Yb *
* 5.double Alfa *
* 6.double Beta *
* 7.double &Xp *
* 8.double &Yp *
* 返回值:无返回值 *
* *
* 注: *
/**************************************************************************/
void Support::ForeIntersecPos(double Xa,double Ya, double Xb,double Yb, double Alfa,double Beta, double &Xp,double &Yp)
{
double ctgA, ctgB;
//计算角a,b的反正切值
ctgA = 1 / tan(Alfa);
ctgB = 1 / tan(Beta);
//计算前方交会定位值
Xp = ((Xa * ctgB + Xb * ctgA) + (Yb - Ya)) / (ctgA + ctgB);
Yp = ((Ya * ctgB + Yb * ctgA) + (Xa - Xb)) / (ctgA + ctgB);
}
/***************************************************************************
* 名字:double CSupport::SplitStringArray(CString str, char split, CStringArray& aStr) *
* *
* 描述:字符串分割函数 *
* *
* 历史:**日期** **理由** **签名** *
* 2019年3月20日 创建该函数 张 *
* 参数: 1.CString str *
* 2.char split *
* 3.CStringArray& aStr *
* 返回值:int类型数据 返回n *
* *
* 注: *
/**************************************************************************/
int Support::SplitStringArray(CString str, char split, CStringArray& aStr)
{
int startIdx = 0;
int idx = str.Find(split, startIdx)