Changeset 13425
- Timestamp:
- May 18, 2007, 4:06:09 AM (19 years ago)
- Location:
- trunk/psLib/src/math
- Files:
-
- 2 edited
-
psEllipse.c (modified) (2 diffs)
-
psEllipse.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psEllipse.c
r13076 r13425 46 46 47 47 // ellipse rotation (major, minor, theta) -> (x2, y2, xy) 48 psEllipseAxes psEllipsePolToAxes(psEllipsePol pol, float minMinorAxis) 48 psErrorCode psEllipsePolToAxes(const psEllipsePol pol, 49 const float minMinorAxis, 50 psEllipseAxes *axes) 49 51 { 50 psEllipseAxes axes;52 axes->theta = +0.5 * atan2 (pol.e2, pol.e1); // theta in radians 51 53 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); 56 56 double ds = 0; 57 57 … … 64 64 float LIMIT = PS_SQR(minMinorAxis); 65 65 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); 68 68 } 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)); 71 71 } 72 72 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 } 76 76 77 return axes;77 return PS_ERR_NONE; 78 78 } 79 79 -
trunk/psLib/src/math/psEllipse.h
r13063 r13425 2 2 * @brief functions to manipulate sparse matrices equations 3 3 * 4 * $Revision: 1. 4$ $Name: not supported by cvs2svn $5 * $Date: 2007-0 4-27 22:13:33$4 * $Revision: 1.5 $ $Name: not supported by cvs2svn $ 5 * $Date: 2007-05-18 14:06:09 $ 6 6 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 7 7 */ … … 9 9 #ifndef PS_ELLIPSE_H 10 10 #define PS_ELLIPSE_H 11 12 #include "psError.h" 11 13 12 14 /// @addtogroup MathOps Mathematical Operations … … 55 57 psEllipsePol psEllipseAxesToPol(psEllipseAxes axes); 56 58 psEllipsePol psEllipseShapeToPol(psEllipseShape shape); 57 psE llipseAxes psEllipsePolToAxes(psEllipsePol pol, float minMinorAxis);59 psErrorCode psEllipsePolToAxes(const psEllipsePol pol, const float minMinorAxis, psEllipseAxes *axes); 58 60 59 61 /// @}
Note:
See TracChangeset
for help on using the changeset viewer.
