Index: trunk/psLib/src/math/psEllipse.c
===================================================================
--- trunk/psLib/src/math/psEllipse.c	(revision 13418)
+++ trunk/psLib/src/math/psEllipse.c	(revision 13425)
@@ -46,12 +46,12 @@
 
 // ellipse rotation (major, minor, theta) -> (x2, y2, xy)
-psEllipseAxes psEllipsePolToAxes(psEllipsePol pol, float minMinorAxis)
+psErrorCode psEllipsePolToAxes(const psEllipsePol pol,
+			       const float minMinorAxis,
+			       psEllipseAxes *axes)
 {
-    psEllipseAxes axes;
+    axes->theta = +0.5 * atan2 (pol.e2, pol.e1); // theta in radians
 
-    axes.theta = +0.5 * atan2 (pol.e2, pol.e1); // theta in radians
-
-    double cs = cos(2*axes.theta);
-    double sn = sin(2*axes.theta);
+    double cs = cos(2*axes->theta);
+    double sn = sin(2*axes->theta);
     double ds = 0;
 
@@ -64,16 +64,16 @@
     float LIMIT = PS_SQR(minMinorAxis);
     if (2.0*(pol.e0 - ds) < LIMIT) {
-	axes.major = sqrt(pol.e0 - LIMIT);
-	axes.minor = sqrt(LIMIT);
+	axes->major = sqrt(pol.e0 - LIMIT);
+	axes->minor = sqrt(LIMIT);
     } else {
-	axes.major = sqrt(0.5*(pol.e0 + ds));
-	axes.minor = sqrt(0.5*(pol.e0 - ds));
+	axes->major = sqrt(0.5*(pol.e0 + ds));
+	axes->minor = sqrt(0.5*(pol.e0 - ds));
     }
 
-    assert (isfinite(axes.major));
-    assert (isfinite(axes.minor));
-    assert (isfinite(axes.theta));
+    if (!isfinite(axes->major) || !isfinite(axes->minor) || !isfinite(axes->theta)) {
+	return psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Shape of object is NaN");
+    }
 
-    return axes;
+    return PS_ERR_NONE;
 }
 
Index: trunk/psLib/src/math/psEllipse.h
===================================================================
--- trunk/psLib/src/math/psEllipse.h	(revision 13418)
+++ trunk/psLib/src/math/psEllipse.h	(revision 13425)
@@ -2,6 +2,6 @@
  * @brief functions to manipulate sparse matrices equations
  *
- * $Revision: 1.4 $ $Name: not supported by cvs2svn $
- * $Date: 2007-04-27 22:13:33 $
+ * $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ * $Date: 2007-05-18 14:06:09 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -9,4 +9,6 @@
 #ifndef PS_ELLIPSE_H
 #define PS_ELLIPSE_H
+
+#include "psError.h"
 
 /// @addtogroup MathOps Mathematical Operations
@@ -55,5 +57,5 @@
 psEllipsePol psEllipseAxesToPol(psEllipseAxes axes);
 psEllipsePol psEllipseShapeToPol(psEllipseShape shape);
-psEllipseAxes psEllipsePolToAxes(psEllipsePol pol, float minMinorAxis);
+psErrorCode psEllipsePolToAxes(const psEllipsePol pol, const float minMinorAxis, psEllipseAxes *axes);
 
 /// @}
