# pike.git/lib/modules/Geography.pmod/Position.pike

Branch: Tag:

## 2003-10-20

#### 2003-10-20 10:27:08 by Mirar (Pontus Hagland) <pike@sort.mirar.org>

• d5f82ececb1efc5aec7cbe67c6232c53c7cdc184 (18 lines) (+15/-3) [ Show | Annotate ]
Branch: 7.9
bugfix in ECEF (it can never have worked), adding an euclidian distance calculator

Rev: lib/modules/Geography.pmod/Position.pike:1.15

478:    float N = equatorial_radius /    sqrt(1-eccentricity_squared()*sin(lat)*sin(lat));    -  float X = (N + alt)*cos(lat)*cos(long); -  float Y = (N + alt)*cos(lat)*sin(long); -  float Z = (N*(1-eccentricity_squared())+alt) * sin(lat); +  constant torad=Math.pi/180; +  float X = (N + alt)*cos(lat*torad)*cos(long*torad); +  float Y = (N + alt)*cos(lat*torad)*sin(long*torad); +  float Z = (N*(1-eccentricity_squared())+alt) * sin(lat*torad);       return ({ X, Y, Z });   }
531:   {    return t=='O' && sprintf("%O(%s, %s)", object_program(this_object()), latitude(), longitude());   } +  + //! Calculate the euclidian distance between two Geography.Position. + //! Result is in meter. This uses the ECEF function. +  + float euclidian_distance(this_program p) + { +  return sqrt(`+(@map(Array.sum_arrays( +  `-,ECEF(),p->ECEF()), +  lambda(float f) { return f*f; }))); + }