IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13959


Ignore:
Timestamp:
Jun 22, 2007, 5:08:40 PM (19 years ago)
Author:
magnier
Message:

more error handling on ellipses

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psEllipse.c

    r13802 r13959  
    110110{
    111111    psEllipseAxes axes;
     112    psEllipseAxes badValue = {NAN, NAN, NAN};
     113
     114    if (!isfinite(moments.x2)) return badValue;
     115    if (!isfinite(moments.y2)) return badValue;
     116    if (!isfinite(moments.xy)) return badValue;
     117
     118    if (moments.x2 < 0) return badValue;
     119    if (moments.y2 < 0) return badValue;
    112120
    113121    double g1 = moments.x2 + moments.y2;
     
    139147{
    140148    psEllipseShape shape;
     149    psEllipseShape badValue = {NAN, NAN, NAN};
     150
     151    if (!isfinite(axes.minor)) return badValue;
     152    if (!isfinite(axes.major)) return badValue;
     153    if (!isfinite(axes.theta)) return badValue;
     154
     155    if (axes.minor <= 0) return badValue;
     156    if (axes.major <= 0) return badValue;
    141157
    142158    double f1 = 1.0 / PS_SQR(axes.minor) + 1.0 / PS_SQR(axes.major);
     
    145161    double sxr = 0.5*f1 - 0.5*f2*cos(2*axes.theta);
    146162    double syr = 0.5*f1 + 0.5*f2*cos(2*axes.theta);
     163
     164    // sxr, syr cannot be < 0 (f1 >= f2)
    147165
    148166    shape.sx  = +1.0 / sqrt(sxr);
Note: See TracChangeset for help on using the changeset viewer.