Diff of /trunk/src/pos.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 39 by harbaum, Fri Dec 12 20:06:32 2008 UTC revision 40 by harbaum, Sun Jan 18 19:43:20 2009 UTC
# Line 160  void pos_lon_label_set(GtkWidget *label, Line 160  void pos_lon_label_set(GtkWidget *label,
160    
161  void pos2lpos(bounds_t *bounds, pos_t *pos, lpos_t *lpos) {  void pos2lpos(bounds_t *bounds, pos_t *pos, lpos_t *lpos) {
162    lpos->x = POS_EQ_RADIUS * DEG2RAD(pos->lon);    lpos->x = POS_EQ_RADIUS * DEG2RAD(pos->lon);
163    #ifdef USE_FLOAT
164      lpos->y = POS_EQ_RADIUS * logf(tanf(M_PI/4 + DEG2RAD(pos->lat)/2));
165    #else
166    lpos->y = POS_EQ_RADIUS * log(tan(M_PI/4 + DEG2RAD(pos->lat)/2));    lpos->y = POS_EQ_RADIUS * log(tan(M_PI/4 + DEG2RAD(pos->lat)/2));
167    #endif
168    lpos->x = ( lpos->x - bounds->center.x) * bounds->scale;    lpos->x = ( lpos->x - bounds->center.x) * bounds->scale;
169    lpos->y = (-lpos->y + bounds->center.y) * bounds->scale;    lpos->y = (-lpos->y + bounds->center.y) * bounds->scale;
170  }  }
# Line 169  void pos2lpos(bounds_t *bounds, pos_t *p Line 172  void pos2lpos(bounds_t *bounds, pos_t *p
172  /* the maps center is special as it isn't offset (by itself) */  /* the maps center is special as it isn't offset (by itself) */
173  void pos2lpos_center(pos_t *pos, lpos_t *lpos) {  void pos2lpos_center(pos_t *pos, lpos_t *lpos) {
174    lpos->x = POS_EQ_RADIUS * DEG2RAD(pos->lon);    lpos->x = POS_EQ_RADIUS * DEG2RAD(pos->lon);
175    #ifdef USE_FLOAT
176      lpos->y = POS_EQ_RADIUS * logf(tanf(M_PI/4 + DEG2RAD(pos->lat)/2));
177    #else
178    lpos->y = POS_EQ_RADIUS * log(tan(M_PI/4 + DEG2RAD(pos->lat)/2));    lpos->y = POS_EQ_RADIUS * log(tan(M_PI/4 + DEG2RAD(pos->lat)/2));
179    #endif
180  }  }
181    
182  void lpos2pos(bounds_t *bounds, lpos_t *lpos, pos_t *pos) {  void lpos2pos(bounds_t *bounds, lpos_t *lpos, pos_t *pos) {
# Line 179  void lpos2pos(bounds_t *bounds, lpos_t * Line 186  void lpos2pos(bounds_t *bounds, lpos_t *
186    tmp.y = (-tmp.y/bounds->scale) + bounds->center.y;    tmp.y = (-tmp.y/bounds->scale) + bounds->center.y;
187    
188    pos->lon = RAD2DEG(tmp.x / POS_EQ_RADIUS);    pos->lon = RAD2DEG(tmp.x / POS_EQ_RADIUS);
189    #ifdef USE_FLOAT
190      pos->lat = RAD2DEG(2 * atanf(expf(tmp.y/POS_EQ_RADIUS)) - M_PI/2);
191    #else
192    pos->lat = RAD2DEG(2 * atan(exp(tmp.y/POS_EQ_RADIUS)) - M_PI/2);    pos->lat = RAD2DEG(2 * atan(exp(tmp.y/POS_EQ_RADIUS)) - M_PI/2);
193    #endif
194  }  }
195    
196  void pos_dist_str(char *str, int len, pos_float_t dist, gboolean is_mil) {  void pos_dist_str(char *str, int len, pos_float_t dist, gboolean is_mil) {

Legend:
Removed from v.39  
changed lines
  Added in v.40