Revision: 55318
http://sourceforge.net/p/brlcad/code/55318
Author: n_reed
Date: 2013-05-07 19:17:55 +0000 (Tue, 07 May 2013)
Log Message:
-----------
oversimplified a bit in r55303, s near zero should become 2pi
Revision Links:
--------------
http://sourceforge.net/p/brlcad/code/55303
Modified Paths:
--------------
brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp
Modified: brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp
===================================================================
--- brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp 2013-05-07 17:18:10 UTC
(rev 55317)
+++ brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp 2013-05-07 19:17:55 UTC
(rev 55318)
@@ -1825,17 +1825,20 @@
#define ANGLE_ZERO_TOL 1.0e-6
-// move rad from [-2pi, 2pi] into [0.0, 2pi]
static double
-normalize_angle(double rad)
+simplify_angle(double rad)
{
- if (NEAR_ZERO(rad, ANGLE_ZERO_TOL)) {
- return 0.0;
- } else if (rad < 0.0) {
- return rad + 2.0 * ON_PI;
+ double result;
+
+ result = fmod(rad, 2.0 * ON_PI);
+
+ if (NEAR_ZERO(result, ANGLE_ZERO_TOL)) {
+ result = 0.0;
+ } else if (result < 0.0) {
+ result += 2.0 * ON_PI;
}
-
- return rad;
+
+ return result;
}
static double
@@ -1915,12 +1918,19 @@
s = radians_from_xaxis_to_ellipse_point(this, endpt);
}
- t = normalize_angle(t);
- s = normalize_angle(s);
- if (s < t) {
- s += 2.0 * ON_PI;
+ t = simplify_angle(t);
+ s = simplify_angle(s);
+
+ if (NEAR_ZERO(s, ANGLE_ZERO_TOL)) {
+ s = 2.0 * ON_PI;
}
+ while (s < t) {
+ double tmp = s;
+ s = t;
+ t = tmp;
+ }
+
// if we have only t and s, get corresponding start and end points
if (parameter_trim) {
startpt = circle.PointAt(t);
@@ -2109,9 +2119,14 @@
s = radians_from_xaxis_to_ellipse_point(this, endpt, a, b);
}
- t = normalize_angle(t);
- s = normalize_angle(s);
- if (s < t) {
+ t = simplify_angle(t);
+ s = simplify_angle(s);
+
+ if (NEAR_ZERO(s, ANGLE_ZERO_TOL)) {
+ s = 2.0 * ON_PI;
+ }
+
+ while (s < t) {
double tmp = s;
s = t;
t = tmp;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits