IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13425


Ignore:
Timestamp:
May 18, 2007, 4:06:09 AM (19 years ago)
Author:
rhl
Message:

Make psEllipsePolToAxes return psErrorCode

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

Legend:

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

    r13076 r13425  
    4646
    4747// ellipse rotation (major, minor, theta) -> (x2, y2, xy)
    48 psEllipseAxes psEllipsePolToAxes(psEllipsePol pol, float minMinorAxis)
     48psErrorCode psEllipsePolToAxes(const psEllipsePol pol,
     49                               const float minMinorAxis,
     50                               psEllipseAxes *axes)
    4951{
    50     psEllipseAxes axes;
     52    axes->theta = +0.5 * atan2 (pol.e2, pol.e1); // theta in radians
    5153
    52     axes.theta = +0.5 * atan2 (pol.e2, pol.e1); // theta in radians
    53 
    54     double cs = cos(2*axes.theta);
    55     double sn = sin(2*axes.theta);
     54    double cs = cos(2*axes->theta);
     55    double sn = sin(2*axes->theta);
    5656    double ds = 0;
    5757
     
    6464    float LIMIT = PS_SQR(minMinorAxis);
    6565    if (2.0*(pol.e0 - ds) < LIMIT) {
    66         axes.major = sqrt(pol.e0 - LIMIT);
    67         axes.minor = sqrt(LIMIT);
     66        axes->major = sqrt(pol.e0 - LIMIT);
     67        axes->minor = sqrt(LIMIT);
    6868    } else {
    69         axes.major = sqrt(0.5*(pol.e0 + ds));
    70         axes.minor = sqrt(0.5*(pol.e0 - ds));
     69        axes->major = sqrt(0.5*(pol.e0 + ds));
     70        axes->minor = sqrt(0.5*(pol.e0 - ds));
    7171    }
    7272
    73     assert (isfinite(axes.major));
    74     assert (isfinite(axes.minor));
    75     assert (isfinite(axes.theta));
     73    if (!isfinite(axes->major) || !isfinite(axes->minor) || !isfinite(axes->theta)) {
     74        return psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Shape of object is NaN");
     75    }
    7676
    77     return axes;
     77    return PS_ERR_NONE;
    7878}
    7979
  • trunk/psLib/src/math/psEllipse.h

    r13063 r13425  
    22 * @brief functions to manipulate sparse matrices equations
    33 *
    4  * $Revision: 1.4 $ $Name: not supported by cvs2svn $
    5  * $Date: 2007-04-27 22:13:33 $
     4 * $Revision: 1.5 $ $Name: not supported by cvs2svn $
     5 * $Date: 2007-05-18 14:06:09 $
    66 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    77 */
     
    99#ifndef PS_ELLIPSE_H
    1010#define PS_ELLIPSE_H
     11
     12#include "psError.h"
    1113
    1214/// @addtogroup MathOps Mathematical Operations
     
    5557psEllipsePol psEllipseAxesToPol(psEllipseAxes axes);
    5658psEllipsePol psEllipseShapeToPol(psEllipseShape shape);
    57 psEllipseAxes psEllipsePolToAxes(psEllipsePol pol, float minMinorAxis);
     59psErrorCode psEllipsePolToAxes(const psEllipsePol pol, const float minMinorAxis, psEllipseAxes *axes);
    5860
    5961/// @}
Note: See TracChangeset for help on using the changeset viewer.