Chinaunix首页 | 论坛 | 博客
  • 博客访问: 335611
  • 博文数量: 92
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 960
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-21 19:38
文章分类

全部博文(92)

文章存档

2010年(71)

2009年(21)

我的朋友

分类: 嵌入式

2010-10-14 15:55:51

结构体做参数的函数

course_angle.h中定义:

struct Zeni_MTS_Position                      //原始坐标点  

{

         float Longitude;                          //位置点纬度,单位度

         float Latitude;                           //位置点经度,单位度

};

struct Zeni_MTS_Position StartPos;            //初始点的坐标

struct Zeni_MTS_Position EndPos;              //终点的坐标

struct Zeni_MTS_Position YawPos;

 

struct Position_MS                            // 数据处理后(毫秒级)坐标点        

{

         float LongitudeMS;                        //位置点纬度,单位毫秒

         float LatitudeMS;                         //位置点经度,单位毫秒

};

struct Position_MS StartPosMS;                //初始点的坐标

struct Position_MS EndPosMS;                  //终点的坐标

struct Position_MS YawPosMS;                  //偏离航线的坐标

struct Position_MS UpLeftMS;                  //左上角坐标

struct Position_MS BottomLeftMS;              //左下角坐标

struct Position_MS UpRightMS;                 //右上角的坐标

struct Position_MS BottomRightMS;             //右下角坐标

struct Position_MS CurrentPostionMS;          //异常点的坐标

 

course_angle.c中定义:

解释一个问题:为什么struct Position_MS *PosMS要加 *

因为我们想要改变*PosMS所指向的那段内存地址中的内容。

unsigned long MSEL(struct Zeni_MTS_Position CoorPos, struct Position_MS *PosMS)

{

         if(CoorPos.Longitude<-180 || CoorPos.Longitude>180 || CoorPos.Latitude<-90 || CoorPos.Latitude>90)

         {

                   printf("Please import right Longitude or Latitude !!!\r\n");

                   PosMS->LatitudeMS = 0;

                   PosMS->LongitudeMS = 0;

         }

         else

         {

                   PosMS->LongitudeMS = Degree_To_MS(CoorPos.Longitude);

                   PosMS->LatitudeMS = Degree_To_MS(CoorPos.Latitude);

         }

         return 0;

 

/************************************************************************/

/*      函数功能:实现航向角的外包函数                                  */

/*      注意:                                                        */

/*      编写:    刘志宇                                                */

/************************************************************************/

 

unsigned long Zeni_MTS_Distance_Angle(struct Zeni_MTS_Position StartPos, struct Zeni_MTS_Position  EndPos, struct Dis_Angle *CouAng)

{

         MSEL(StartPos, &StartPosMS);

         MSEL(EndPos, &EndPosMS);

         CouAng->yDistance = SN_Distance(StartPosMS, EndPosMS);

         CouAng->xDistance = EW_Distance(StartPosMS, EndPosMS);

         CouAng->Cour_Distance = Distance(CouAng->xDistance, CouAng->yDistance);

         CouAng->Cour_Angle = Course_Angle(CouAng->xDistance, CouAng->yDistance);

         return 0;

}

 

}

 

阅读(1594) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~