protected LatLon greatCircleIntersectionAtLongitude(LatLon p1,LatLon p2,Angle longitude){
  if (p1.getLongitude().degrees == longitude.degrees)   return p1;
  if (p2.getLongitude().degrees == longitude.degrees)   return p2;
  LatLon pos=null;
  Double deltaLon=getDeltaLongitude(p1,p2.getLongitude()).degrees;
  if (getDeltaLongitude(p1,longitude).degrees < deltaLon && getDeltaLongitude(p2,longitude).degrees < deltaLon) {
    int count=0;
    double precision=1d / 6378137d;
    LatLon a=p1;
    LatLon b=p2;
    LatLon midPoint=greatCircleMidPoint(a,b);
    while (getDeltaLongitude(midPoint,longitude).radians > precision && count <= 20) {
      count++;
      if (getDeltaLongitude(a,longitude).degrees < getDeltaLongitude(b,longitude).degrees)       b=midPoint;
 else       a=midPoint;
      midPoint=greatCircleMidPoint(a,b);
    }
    pos=midPoint;
  }
  if (pos != null)   pos=new LatLon(pos.getLatitude(),longitude);
  return pos;
}

protected LatLon greatCircleIntersectionAtLongitude ( LatLon p1 , LatLon p2 , Angle longitude ) { if ( p1 . getLongitude ( ) . degrees == longitude . degrees ) return p1 ; if ( p2 . getLongitude ( ) . degrees == longitude . degrees ) return p2 ; LatLon pos = null ; Double deltaLon = getDeltaLongitude ( p1 , p2 . getLongitude ( ) ) . degrees ; if ( getDeltaLongitude ( p1 , longitude ) . degrees < deltaLon && getDeltaLongitude ( p2 , longitude ) . degrees < deltaLon ) { int count = 0 ; double precision = 1d / 6378137d ; LatLon a = p1 ; LatLon b = p2 ; LatLon midPoint = greatCircleMidPoint ( a , b ) ; while ( getDeltaLongitude ( midPoint , longitude ) . radians > precision && count <= 20 ) { count ++ ; if ( getDeltaLongitude ( a , longitude ) . degrees < getDeltaLongitude ( b , longitude ) . degrees ) b = midPoint ; else a = midPoint ; midPoint = greatCircleMidPoint ( a , b ) ; } pos = midPoint ; } if ( pos != null ) pos = new LatLon ( pos . getLatitude ( ) , longitude ) ; return pos ; }
computes the intersection point position between a great circle segment and a meridian .
