text: Q:
  
  GPS coordinates in degrees to calculate distances
  
  On the iPhone, I get the user's location in decimal degrees, for example: latitude 39.470920 and longitude = -0.373192; That's point A.
  I need to create a line with another GPS coordinate, also in decimal degrees, point B. Then, calculate the distance (perpendicular) between the line from A to B and another point C.
  The problem is I get confused with the values in degrees. I would like to have the result in meters. What's the conversion needed? How will the final formula to compute this look like?
  
  A:
  
  use - (CLLocationDistance)getDistanceFrom:(const CLLocation *)location
  firstLongitude = 30.0;
  firstLatitude = 30.0;
  
  secondLongitude = 40.0;
  secondLatitude = 40.0;
  
  CLLocation *firstLoc = [[CLLocation alloc]initWithLatitude:firstLatitude longitude: firstLongitude];
  CLLocation *secondLoc = [[CLLocation alloc]initWithLatitude:secondLatitude longitude: secondLongitude];
  
  double distanceInMeters = [firstLoc getDistanceFrom: secondLoc];
  
  A:
  
  Your problem is non-trivial: On a spheroid, there might even be more than one line perpendicular to AB through C.
  If the distances are small, you might get away with the euclidian approximation
  Δx = R·cosα·Δλ
  Δy = r·Δφ
  
  r = b²/√(b² + (a² - b²)·cos²φ)
  R·cosα = a²/√(a² + b²·tan²φ)
  
  with latitude φ, longitude λ, semimajor axis a and semiminor axis b; in spherical approximation a = b. The φ in the formulae for r and R·cosα has to be some sort of mean value.
  metric on spheroid http://img263.imageshack.us/img263/3620/spheroid.gif
  An approach which might give better results would be to solve the problem in 3-space (and not on the surface of the spheroid) and get the arc length associated with the connecting line.
  To do this, you need to know how to convert from geographical coordinates with normal angle φ to cartesian coordinates
  z = b²·sinφ/√(a²·cos²φ + b²·sin²φ)
  r = a²·cosφ/√(a²·cos²φ + b²·sin²φ)
  x = r·cosλ
  y = r·sinλ
  
  and from geocentrical coordinates with polar angle α to cartesian coordinates
  z = a·b·sinα/√(a²·sin²α + b²·cos²α)
  r = a·b·cosα/√(a²·sin²α + b²·cos²α)
  x = r·cosλ
  y = r·sinλ
  
  Note that the r in these formulae is different from the one in the picture above.
  Let A, B, C be the vectors in euclidian space corresponding to your points on the spheroid's surface. The foot of perpendicular F is given by
  F = 1/|B-A|² · (<B-A,C-A>·B - <B-A,C-B>·A)
  
  where <,> is the scalar product and |·| the norm.
  Now, we have to determine the point F' on the spheroid's surface corresponding to F, which means we'll have to compute
  λ' = atan2(y,x)
  α' = arctan(z/√(x² + y²))
  
  and then convert these back to cartesian coordinates.
  The length of the secant is given by
  d = |F'- C|
  
  The corresponding arc length in spherical approximation is
  s = R·β
  
  where β is the angle between F' and C, ie
  β = arccos(cosβ) = arccos(<F',C>/(|F'|·|C|))
  
  and R is either the mean radius given by
  R = ³√(a²·b)
  
  or using the cosine rule for a better value for small distances
  R = d/√(2·(1 - cosβ))
  
  