Revision: 41007
http://brlcad.svn.sourceforge.net/brlcad/?rev=41007&view=rev
Author: r_weiss
Date: 2010-10-15 21:13:22 +0000 (Fri, 15 Oct 2010)
Log Message:
-----------
Fixed some bugs in function bn_coplanar.
Modified Paths:
--------------
brlcad/trunk/src/libbn/plane.c
Modified: brlcad/trunk/src/libbn/plane.c
===================================================================
--- brlcad/trunk/src/libbn/plane.c 2010-10-15 21:05:47 UTC (rev 41006)
+++ brlcad/trunk/src/libbn/plane.c 2010-10-15 21:13:22 UTC (rev 41007)
@@ -2192,20 +2192,24 @@
register fastf_t f;
register fastf_t dot;
vect_t pt_a, pt_b;
-
BN_CK_TOL(tol);
+ if (!NEAR_ZERO(MAGSQ(a) - 1.0, VUNITIZE_TOL) || !NEAR_ZERO(MAGSQ(b) - 1.0,
VUNITIZE_TOL)) {
+ bu_bomb("bn_coplanar(): input vector(s) 'a' and/or 'b' is not a unit
vector.\n");
+ }
+
dot = VDOT(a, b);
VSCALE(pt_a, a, a[3]);
VSCALE(pt_b, b, b[3]);
- if (NEAR_ZERO(MAGSQ(pt_a), SQRT_SMALL_FASTF) || NEAR_ZERO(MAGSQ(pt_b),
SQRT_SMALL_FASTF)) {
- bu_bomb("bn_coplanar(): zero magnitude input vector\n");
+ if (NEAR_ZERO(dot, SMALL_FASTF)) {
+ return 0; /* planes are perpendicular */
}
- if ((dot < 0) ? (-dot >= (1 - SMALL_FASTF)) : (dot >= (1 - SMALL_FASTF)))
{ /* test for parallel */
+ /* parallel is when dot is within SMALL_FASTF of either -1 or 1 */
+ if ((dot <= -SMALL_FASTF) ? (NEAR_ZERO(dot + 1.0, SMALL_FASTF)) :
(NEAR_ZERO(dot - 1.0, SMALL_FASTF))) {
if (bn_pt3_pt3_equal(pt_a, pt_b, tol)) { /* test for coplanar */
- if ( dot > 0 ) { /* test normals in same direction */
+ if ( dot >= SMALL_FASTF) { /* test normals in same direction */
return 1;
} else {
return 2;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits