Revision: 41279
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41279&view=rev
Author:   brlcad
Date:     2010-11-08 16:18:59 +0000 (Mon, 08 Nov 2010)

Log Message:
-----------
use vmath macros where equivalent for moving, scaling, and transposing.  V3ARGS 
for args.  avoid bombing at all costs unless if there is no sensible return 
possible, return a zero output if input is zero.

Modified Paths:
--------------
    brlcad/trunk/src/libbn/mat.c

Modified: brlcad/trunk/src/libbn/mat.c
===================================================================
--- brlcad/trunk/src/libbn/mat.c        2010-11-08 15:58:42 UTC (rev 41278)
+++ brlcad/trunk/src/libbn/mat.c        2010-11-08 16:18:59 UTC (rev 41279)
@@ -381,9 +381,7 @@
 void
 bn_vtoh_move(register vect_t h, register const vect_t v)
 {
-    h[X] = v[X];
-    h[Y] = v[Y];
-    h[Z] = v[Z];
+    VMOVE(h, v);
     h[W] = 1.0;
 }
 
@@ -403,18 +401,14 @@
     register fastf_t inv;
 
     if (NEAR_ZERO(h[3] - 1.0, SMALL_FASTF)) {
-       v[X] = h[X];
-       v[Y] = h[Y];
-       v[Z] = h[Z];
+       VMOVE(v, h);
     } else {
        if (NEAR_ZERO(h[W], SMALL_FASTF)) {
            bu_log("bn_htov_move: divide by %f!\n", h[W]);
            return;
        }
        inv = 1.0 / h[W];
-       v[X] = h[X] * inv;
-       v[Y] = h[Y] * inv;
-       v[Z] = h[Z] * inv;
+       VSCALE(v, h, inv);
     }
 }
 
@@ -425,27 +419,7 @@
 void
 bn_mat_trn(mat_t om, register const mat_t im)
 {
-    register matp_t op = om;
-
-    *op++ = im[0];
-    *op++ = im[4];
-    *op++ = im[8];
-    *op++ = im[12];
-
-    *op++ = im[1];
-    *op++ = im[5];
-    *op++ = im[9];
-    *op++ = im[13];
-
-    *op++ = im[2];
-    *op++ = im[6];
-    *op++ = im[10];
-    *op++ = im[14];
-
-    *op++ = im[3];
-    *op++ = im[7];
-    *op++ = im[11];
-    *op++ = im[15];
+    MAT_TRANSPOSE(om, im);
 }
 
 
@@ -1043,7 +1017,7 @@
     /* Check the final results */
     MAT4X3VEC(t1, rot, dir);
     if (t1[Z] > -0.98) {
-       bu_log("Error:  bn_mat_lookat final= (%g, %g, %g)\n", t1[X], t1[Y], 
t1[Z]);
+       bu_log("Error:  bn_mat_lookat final= (%g, %g, %g)\n", V3ARGS(t1));
     }
 }
 
@@ -1065,9 +1039,9 @@
     register int i;
 
     if (NEAR_ZERO(MAGSQ(in), SQRT_SMALL_FASTF)) {
+       bu_log("bn_vec_ortho(): zero magnitude input vector %lf %lf %lf\n", 
V3ARGS(in));
        VSETALL(out, 0);
-       bu_log("bn_vec_ortho(): zero magnitude input vector %lf %lf %lf\n", 
in[0],in[1],in[2]);
-       bu_bomb("bn_vec_ortho(): zero magnitude input vector\n");
+       return;
     }
 
     /* Find component closest to zero */
@@ -1088,7 +1062,7 @@
     }
     f = hypot(in[j], in[k]);
     if (NEAR_ZERO(f, SMALL_FASTF)) {
-       bu_log("bn_vec_ortho(): zero hypot on %lf %lf %lf\n", 
in[0],in[1],in[2]);
+       bu_log("bn_vec_ortho(): zero hypot on %lf %lf %lf\n", V3ARGS(in));
        VSETALL(out, 0);
        return;
     }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to