convert_coord.h

来自「用于2维的射线追踪」· C头文件 代码 · 共 65 行

H
65
字号
#ifndef _CONVERT_COORD_H_#define _CONVERT_COORD_H_#ifndef _COORD_3D_H_#define _COORD_3D_H_struct point3d_t {     float lat;          /**< latitude */     float lon;          /**< longitude */     float prf;          /**< depth */};#endif#ifndef _COORD_GEO_H_#define _COORD_GEO_H_struct coord_geo_t {       double lat; /**< latitude   */       double lon; /**< longitude (in rad or degree ?) */       double prof;/**< depth (in km)*/};#endif                                                                                                        #ifndef _COORD_CART_H_#define _COORD_CART_H_struct coord_cart_t {       double x;   /**< plan xy axe equateur */       double y;   /**< plan xz axe meridien origine */       double z;         /**< depth (in kms) */};#endif#if defined _COORD_GEO_H_ && defined _COORD_3D_H_struct coord_geo_t * point3d2geo( struct point3d_t *p) {	  struct coord_geo_t *g=malloc(sizeof(struct coord_geo_t));	  g->lat = p->lat * TO_RAD;	  g->lon = p->lon * TO_RAD;	  g->prof = p->prf;	  return(g);}#endif#if defined _COORD_CART_H_ && defined _COORD_3D_H_/** * coordinates transformation : point3d (georaphic) (angles are in radians) * coordinates to cartesian coordinates                            */ struct coord_cart_t * point3d2cart ( const struct point3d_t *point3d) {	struct coord_cart_t *coord_cart;	double r, cos_lat, sin_lat, cos_lon, sin_lon;	coord_cart =  (struct coord_cart_t *) malloc (sizeof (struct coord_cart_t));	assert (coord_cart);	r = RE - point3d->prf;	cos_lat = cos (point3d->lat * TO_RAD);	sin_lat = sin (point3d->lat * TO_RAD);	cos_lon = cos (point3d->lon * TO_RAD);	sin_lon = sin (point3d->lon * TO_RAD);		coord_cart->x = r * cos_lat * cos_lon;	coord_cart->y = r * cos_lat * sin_lon;	coord_cart->z = r * sin_lat;		return (coord_cart);}#endif#endif

⌨️ 快捷键说明

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