资源简介
这个不是现成的工具,而是具体的C语言代码功能实现。利用C语言实现了大地坐标系和空间直角坐标系的相互转换,以及求解七参数的值的方法。

代码片段和文件信息
#include
#include
#include
#include
#include “commons.h“
#define PI 3.1415926
#define true 1
#define false 0
typedef int bool;
/*
从角度换算为弧度
参数格式:[-]ddmmss.ssss
*/
double dmsToDegree(double dms)
{
bool flag=false;
if(dms<0)
{
flag=true;
dms=-dms;
}
int d=(int)(dms / 10000);
int m=(int)((dms - d*10000) / 100);
double s=dms - 10000 * d - 100 * m;
printf(“%d %d %lf\n“dms);
double degree = (d + m/60.0 + s/3600)* PI / 180;
return flag ? -degree : degree;
}
/*
计算两点间的平面距离
*/
float planeDist(struct Point *ptAstruct Point *ptB)
{
float dist=sqrt((ptA->x-ptB->x)*(ptA->x-ptB->x)+(ptA->y-ptB->y)*(ptA->y-ptB->y));
return dist;
}
/*
计算两条直线的交点
*/
struct Point *intersection(struct Line *aLinestruct Line *bLine)
{
if(aLine->A==0 && bLine->A==0 && aLine->B!=bLine->B)
return NULL;
if(aLine->B==0 && bLine->B==0 && aLine->A!=bLine->A)
return NULL;
if(aLine->A*bLine->B == aLine->B*bLine->A)
return NULL;
struct Point *pt=(struct Point*)malloc(sizeof(struct Point));
if(aLine->A==0 && bLine->B==0)
{
pt->x=-bLine->C / bLine->A;
pt->y=-aLine->C / aLine->B;
return pt;
}
if(aLine->B==0 && bLine->A==0)
{
pt->x=-aLine->C / aLine->A;
pt->y=-bLine->C / bLine->B;
return pt;
}
float x=(aLine->C * bLine->B - bLine->C * aLine->B) / (aLine->B * bLine->A - bLine->B * aLine->A);
float y=(bLine->C * aLine->A - aLine->C * bLine->A) / (aLine->B * bLine->A - bLine->B * aLine->A);
pt->x=x;
pt->y=y;
return pt;
}
/*
两点确定一条直线
*/
struct Line *makeLine(struct Point *ptAstruct Point *ptB)
{
struct Line *line=(struct Line*)malloc(sizeof(struct Line));
if(ptA->x == ptB->x && ptA->y == ptB->y)
return NULL;
else if(ptA->x == ptB->x)
{
line->A=1;
line->B=0;
line->C=-ptA->x;
}
else if(ptA->y == ptB->y)
{
line->A=0;
line->B=1;
line->C=-ptA->y;
}
else
{
line->A=(ptA->y - ptB->y) / (ptB->x - ptA->x);
line->B=1;
line->C=(ptB->x * ptA->y - ptA->x * ptB->y)/(ptA->x - ptB->x);
}
return line;
}
/*
计算两条直线的夹角,返回弧度
*/
float dimangular(struct Line *aLinestruct Line* bLine)
{
if(aLine->B==0)
{
if(bLine->B==0) return 0;
if(bLine->A==0) return PI/2;
return PI/2 - atan(-bLine->A / bLine->B);
}
else
{
if(bLine->B==0) return PI/2-atan(-aLine->A / aLine->B);
float k1=-aLine->A/aLine->B;
float k2=-bLine->A/bLine->B;
return atan(fabs(k1-k2)/(1+k1*k2));
}
}
/*
计算点到直线的距离
*/
float lineDist(struct Line *linestruct Point *pt)
{
return fabs(line->A*pt->x + line->B*pt->y + line->C)/sqrt(line->A*line->A + line->B*line->B);
}
//Matrix operation
//分配矩阵空间
struct Matrix *mallocMatrix(int rowsint columns)
{
struct Matrix *mat=(struct Matrix*)malloc(sizeof(struct Matrix));
int i;
mat->rows = rows;
mat->columns = columns;
mat->data=(double**)malloc(mat->rows * sizeof(double*));
for(i=0;i mat->data[i]=(double*)malloc(sizeof(double) * mat->columns);
return mat;
}
//initialize
struct Matrix *initMatrix(int rowsint columnsdouble a[rows][columns])
{
int ij;
struc
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-11-12 11:21 GisCTest\
文件 11549 2020-11-12 10:55 GisCTest\.cproject
文件 2147 2020-11-12 10:55 GisCTest\.project
目录 0 2020-11-10 16:32 GisCTest\.settings\
文件 1166 2020-11-10 16:12 GisCTest\.settings\org.eclipse.cdt.managedbuilder.core.prefs
文件 62 2020-11-10 16:32 GisCTest\.settings\org.eclipse.core.resources.prefs
目录 0 2020-11-12 11:21 GisCTest\Debug\
文件 156002 2020-11-12 11:21 GisCTest\Debug\GisCTest.exe
目录 0 2020-11-12 11:21 GisCTest\Debug\src\
文件 42789 2020-11-12 11:21 GisCTest\Debug\src\commons.o
文件 26474 2020-11-12 11:21 GisCTest\Debug\src\CTest.o
文件 51745 2020-11-12 11:21 GisCTest\Debug\src\geodesy.o
目录 0 2020-11-12 10:55 GisCTest\src\
文件 9389 2020-11-11 09:44 GisCTest\src\commons.c
文件 1294 2020-11-10 16:36 GisCTest\src\commons.h
文件 2011 2020-11-12 11:21 GisCTest\src\CTest.c
文件 11981 2020-11-11 17:36 GisCTest\src\geodesy.c
文件 1537 2020-11-11 17:22 GisCTest\src\geodesy.h
相关资源
- 操作系统c语言模拟文件管理系统844
- C语言开发实战宝典
- C++中头文件与源文件的作用详解
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- 个人日常财务管理系统(C语言)
- c语言电子商务系统
- 小甲鱼C语言课件 源代码
- 将图片转换为C语言数组的程序
- C语言实现的一个内存泄漏检测程序
- DES加密算法C语言实现
- LINUX下命令行界面的C语言细胞游戏
- 用单片机控制蜂鸣器播放旋律程序(
- 学校超市选址问题(数据结构C语言版
- 电子时钟 有C语言程序,PROTEUS仿真图
- 尚观培训linux许巍老师关于c语言的课
评论
共有 条评论