IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25189


Ignore:
Timestamp:
Aug 25, 2009, 2:54:49 PM (17 years ago)
Author:
Paul Price
Message:

Had latitude and longitude around the wrong way for Haversine formula....

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_mops/psLib/src/types/psTree.c

    r25180 r25189  
    428428        switch (dim) {
    429429          case 2: {
    430               double dphi = coords->data.F64[0] - tree->data->F64[index][0];
    431               double dlambda = coords->data.F64[1] - tree->data->F64[index][1];
     430              // Haversine formula
     431              double dphi = coords->data.F64[1] - tree->data->F64[index][1];
    432432              double sindphi = sin(dphi / 2.0);
     433              double dlambda = coords->data.F64[0] - tree->data->F64[index][0];
    433434              double sindlambda = sin(dlambda / 2.0);
    434435              return PS_SQR(sindphi) +
    435                   cos(coords->data.F64[0]) * cos(coords->data.F64[0]) * PS_SQR(sindlambda);
     436                  cos(coords->data.F64[1]) * cos(tree->data->F64[index][1]) * PS_SQR(sindlambda);
    436437          }
    437438          default:
Note: See TracChangeset for help on using the changeset viewer.