private static double scoreSequence(List<LatLong> pts){
  LatLong prev=pts.get(pts.size() - 1);
  LatLong prevprev=pts.get(pts.size() - 2);
  double prevAngle=Math.atan2(prev.lat - prevprev.lat,prev.lng - prevprev.lng);
  double score=0;
  for (  LatLong pt : pts) {
    double angle=Math.atan2(pt.lat - prev.lat,pt.lng - prev.lng);
    double diff=prevAngle - angle;
    if (diff > Math.PI)     diff-=Math.PI * 2;
 else     if (diff < -Math.PI)     diff+=Math.PI * 2;
    if (diff < 0)     score+=10;
 else     score+=diff;
    prev=pt;
    prevAngle=angle;
  }
  return score;
}

private static double scoreSequence ( List < LatLong > pts ) { LatLong prev = pts . get ( pts . size ( ) - 1 ) ; LatLong prevprev = pts . get ( pts . size ( ) - 2 ) ; double prevAngle = Math . atan2 ( prev . lat - prevprev . lat , prev . lng - prevprev . lng ) ; double score = 0 ; for ( LatLong pt : pts ) { double angle = Math . atan2 ( pt . lat - prev . lat , pt . lng - prev . lng ) ; double diff = prevAngle - angle ; if ( diff > Math . PI ) diff -= Math . PI * 2 ; else if ( diff < - Math . PI ) diff += Math . PI * 2 ; if ( diff < 0 ) score += 10 ; else score += diff ; prev = pt ; prevAngle = angle ; } return score ; }
how ' good ' does this sequence of points look ? the sequence must be clockwise and have the least acute angles possible .
