Revision: 41498
http://brlcad.svn.sourceforge.net/brlcad/?rev=41498&view=rev
Author: r_weiss
Date: 2010-12-03 20:54:30 +0000 (Fri, 03 Dec 2010)
Log Message:
-----------
Updated functions bn_coplanar and bn_isect_line3_line3. Removed the magic
number tolerances. Also made additional tolerance changes which should improve
facetize and 'ev'. Currently in process of testing. Initial results appear good.
Modified Paths:
--------------
brlcad/trunk/src/libbn/plane.c
Modified: brlcad/trunk/src/libbn/plane.c
===================================================================
--- brlcad/trunk/src/libbn/plane.c 2010-12-03 18:22:32 UTC (rev 41497)
+++ brlcad/trunk/src/libbn/plane.c 2010-12-03 20:54:30 UTC (rev 41498)
@@ -1235,6 +1235,7 @@
int parallel = 0;
int colinear = 0;
+
BN_CK_TOL(tol);
if (NEAR_ZERO(MAGSQ(c), VUNITIZE_TOL) || NEAR_ZERO(MAGSQ(d),
VUNITIZE_TOL)) {
@@ -1253,12 +1254,11 @@
VCROSS(n, d, c);
det = VDOT(n, p) - VDOT(n, a);
-
- if (!NEAR_ZERO(det, 1.0e-10)) {
+ if (!NEAR_ZERO(det, tol->perp)) {
return -1; /* no intersection, lines not in same plane */
}
- if (NEAR_ZERO(MAGSQ(n), 1.0e-19)) {
+ if (NEAR_ZERO(MAGSQ(n), VUNITIZE_TOL)) {
/* lines are parallel, must find another way to get normal vector */
vect_t a_to_p;
@@ -1266,7 +1266,7 @@
VSUB2(a_to_p, p, a);
VCROSS(n, a_to_p, d);
- if (NEAR_ZERO(MAGSQ(n), 1.0e-19)) {
+ if (NEAR_ZERO(MAGSQ(n), VUNITIZE_TOL)) {
/* lines are parallel and colinear */
colinear = 1;
@@ -1274,7 +1274,7 @@
}
}
- if (NEAR_ZERO(MAGSQ(n), 1.0e-19)) {
+ if (NEAR_ZERO(MAGSQ(n), VUNITIZE_TOL)) {
bu_bomb("bn_isect_line3_line3(): ortho vector zero magnitude\n");
}
@@ -1370,11 +1370,13 @@
*/
VSUB2(h, a, p);
det = c[q] * d[r] - d[q] * c[r];
- det1 = (c[q] * h[r] - h[q] * c[r]);
-
- if (NEAR_ZERO(det, 1.0e-10)) {
+ det1 = (c[q] * h[r] - h[q] * c[r]); /* see below */
+ /* XXX This should be no smaller than 1e-16. See
+ * bn_isect_line2_line2 for details.
+ */
+ if (NEAR_ZERO(det, VUNITIZE_TOL)) {
/* Lines are parallel */
- if (!colinear || !NEAR_ZERO(det1, DETERMINANT_TOL)) {
+ if (!colinear || !NEAR_ZERO(det1, VUNITIZE_TOL)) {
return -2; /* parallel, not colinear, no intersection */
}
@@ -1418,9 +1420,15 @@
/* Check that these values of t and u satisfy the 3rd equation as
* well!
+ *
+ * XXX It isn't clear that "det" is exactly a model-space
+ * distance.
*/
det = *t * d[s] - *u * c[s] - h[s];
- if (!NEAR_ZERO(det, 1.0e-23)) {
+ if (!NEAR_ZERO(det, VUNITIZE_TOL)) {
+ /* XXX This tolerance needs to be much less loose than
+ * SQRT_SMALL_FASTF. What about DETERMINANT_TOL?
+ */
/* Inconsistent solution, lines miss each other */
return -1;
}
@@ -2236,16 +2244,15 @@
}
dot = VDOT(a, b);
-
VSCALE(pt_a, a, a[3]);
VSCALE(pt_b, b, b[3]);
- if (NEAR_ZERO(dot, 1.0e-8)) {
+ if (NEAR_ZERO(dot, tol->perp)) {
return 0; /* planes are perpendicular */
}
- /* parallel is when dot is within 4.5e-16 of either -1 or 1 */
- if ((dot <= -SMALL_FASTF) ? (NEAR_ZERO(dot + 1.0, 4.5e-16)) :
(NEAR_ZERO(dot - 1.0, 4.5e-16))) {
+ /* parallel is when dot is within tol->perp of either -1 or 1 */
+ if ((dot <= -SMALL_FASTF) ? (NEAR_ZERO(dot + 1.0, tol->perp)) :
(NEAR_ZERO(dot - 1.0, tol->perp))) {
if (bn_pt3_pt3_equal(pt_a, pt_b, tol)) {
/* test for coplanar */
if (dot >= SMALL_FASTF) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits