IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19996


Ignore:
Timestamp:
Oct 8, 2008, 11:51:34 AM (18 years ago)
Author:
eugene
Message:

modify the error handling for psEllipsePolToAxes

Location:
trunk/psLib/src/math
Files:
2 edited

Legend:

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

    r13959 r19996  
    66#include <assert.h>
    77#include "psConstants.h"
     8#include "psTrace.h"
    89#include "psEllipse.h"
    910
     
    4748// ellipse rotation (major, minor, theta) -> (x2, y2, xy)
    4849// XXXX handle case where e0 < LIMIT
    49 psErrorCode psEllipsePolToAxes(const psEllipsePol pol,
    50                                const float minMinorAxis,
    51                                psEllipseAxes *axes)
    52 {
    53     axes->theta = +0.5 * atan2 (pol.e2, pol.e1); // theta in radians
    54 
    55     double cs = cos(2*axes->theta);
    56     double sn = sin(2*axes->theta);
     50psEllipseAxes psEllipsePolToAxes(const psEllipsePol pol,
     51                                 const float minMinorAxis)
     52{
     53    psEllipseAxes axes;
     54
     55    axes.theta = +0.5 * atan2 (pol.e2, pol.e1); // theta in radians
     56
     57    double cs = cos(2*axes.theta);
     58    double sn = sin(2*axes.theta);
    5759    double ds = 0;
    5860
     
    6668    if (pol.e0 < LIMIT) {
    6769        // if e0 is too small, we are really out of luck
    68         axes->major = minMinorAxis;
    69         axes->minor = minMinorAxis;
     70        axes.major = minMinorAxis;
     71        axes.minor = minMinorAxis;
    7072    } else {
    7173        if (2.0*(pol.e0 - ds) < LIMIT) {
    7274            // if e0 - ds is too small, saturate the minor axis at minMinorAxis
    73             axes->major = sqrt(pol.e0 - LIMIT);
    74             axes->minor = sqrt(LIMIT);
     75            axes.major = sqrt(pol.e0 - LIMIT);
     76            axes.minor = sqrt(LIMIT);
    7577        } else {
    7678            // normal values for e0 & ds
    77             axes->major = sqrt(0.5*(pol.e0 + ds));
    78             axes->minor = sqrt(0.5*(pol.e0 - ds));
     79            axes.major = sqrt(0.5*(pol.e0 + ds));
     80            axes.minor = sqrt(0.5*(pol.e0 - ds));
    7981        }
    8082    }
    8183
    82     if (!isfinite(axes->major) || !isfinite(axes->minor) || !isfinite(axes->theta)) {
    83         return psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Shape of object is NaN");
    84     }
    85 
    86     return PS_ERR_NONE;
     84    if (!isfinite(axes.major) || !isfinite(axes.minor) || !isfinite(axes.theta)) {
     85        psTrace ("psLib.math", 5, "Shape of object is NaN");
     86    }
     87    return axes;
    8788}
    8889
  • trunk/psLib/src/math/psEllipse.h

    r15794 r19996  
    22 * @brief functions to manipulate sparse matrices equations
    33 *
    4  * $Revision: 1.6 $ $Name: not supported by cvs2svn $
    5  * $Date: 2007-12-12 21:01:32 $
     4 * $Revision: 1.7 $ $Name: not supported by cvs2svn $
     5 * $Date: 2008-10-08 21:51:34 $
    66 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    77 */
     
    7676///
    7777/// XXX This API goes against the PS convention of outputs being first.
    78 psErrorCode psEllipsePolToAxes(const psEllipsePol pol, ///< Polarisation of ellipse
    79                                const float minMinorAxis, ///< Minimum allowed minor axis
    80                                psEllipseAxes *axes ///< Output ellipse axes
    81                                );
     78psEllipseAxes psEllipsePolToAxes(const psEllipsePol pol, ///< Polarisation of ellipse
     79                                 const float minMinorAxis ///< Minimum allowed minor axis
     80    );
    8281
    8382/// @}
Note: See TracChangeset for help on using the changeset viewer.