Changeset 19996
- Timestamp:
- Oct 8, 2008, 11:51:34 AM (18 years ago)
- Location:
- trunk/psLib/src/math
- Files:
-
- 2 edited
-
psEllipse.c (modified) (3 diffs)
-
psEllipse.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psEllipse.c
r13959 r19996 6 6 #include <assert.h> 7 7 #include "psConstants.h" 8 #include "psTrace.h" 8 9 #include "psEllipse.h" 9 10 … … 47 48 // ellipse rotation (major, minor, theta) -> (x2, y2, xy) 48 49 // 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); 50 psEllipseAxes 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); 57 59 double ds = 0; 58 60 … … 66 68 if (pol.e0 < LIMIT) { 67 69 // 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; 70 72 } else { 71 73 if (2.0*(pol.e0 - ds) < LIMIT) { 72 74 // 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); 75 77 } else { 76 78 // 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)); 79 81 } 80 82 } 81 83 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; 87 88 } 88 89 -
trunk/psLib/src/math/psEllipse.h
r15794 r19996 2 2 * @brief functions to manipulate sparse matrices equations 3 3 * 4 * $Revision: 1. 6$ $Name: not supported by cvs2svn $5 * $Date: 200 7-12-12 21:01:32$4 * $Revision: 1.7 $ $Name: not supported by cvs2svn $ 5 * $Date: 2008-10-08 21:51:34 $ 6 6 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 7 7 */ … … 76 76 /// 77 77 /// 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 ); 78 psEllipseAxes psEllipsePolToAxes(const psEllipsePol pol, ///< Polarisation of ellipse 79 const float minMinorAxis ///< Minimum allowed minor axis 80 ); 82 81 83 82 /// @}
Note:
See TracChangeset
for help on using the changeset viewer.
