Browse Source

cleaned up verbose outputs

Former-commit-id: 4c2f6a0063babb622c78cc4880c2584afac30908
jalec 13 years ago
parent
commit
8df094f330
8 changed files with 46 additions and 18 deletions
  1. 1 1
      axis_angle_to_quat.h
  2. 3 0
      colon.h
  3. 0 3
      list_to_matrix.h
  4. 25 2
      matlab-to-eigen.html
  5. 1 0
      min_quad_with_fixed.h
  6. 1 0
      sparse.h
  7. 8 7
      trackball.h
  8. 7 5
      writeDMAT.h

+ 1 - 1
axis_angle_to_quat.h

@@ -1,7 +1,7 @@
 #ifndef IGL_AXIS_ANGLE_TO_QUAT_H
 #define IGL_AXIS_ANGLE_TO_QUAT_H
 
-#include <EPS.h>
+#include "EPS.h"
 #include <cmath>
 namespace igl
 {

+ 3 - 0
colon.h

@@ -3,6 +3,9 @@
 #include <Eigen/Dense>
 namespace igl
 {
+  // Note:
+  // This should be potentially replaced with eigen's LinSpaced() function
+
   // Colon operator like matlab's colon operator. Enumerats values between low
   // and hi with step step.
   // Templates:

+ 0 - 3
list_to_matrix.h

@@ -32,7 +32,6 @@ bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M)
 {
   // number of columns
   int m = V.size();
-  verbose("m = %d\n",m);
   if(m == 0)
   {
     fprintf(stderr,"Error: list_to_matrix() list is empty()\n");
@@ -40,8 +39,6 @@ bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M)
   }
   // number of rows
   int n = igl::min_size(V);
-  verbose("min = %d\n",igl::min_size(V));
-  verbose("max = %d\n",igl::max_size(V));
   if(n != igl::max_size(V))
   {
     fprintf(stderr,"Error: list_to_matrix()"

+ 25 - 2
matlab-to-eigen.html

@@ -1,5 +1,4 @@
-<html>
-  <head>
+<html> <head>
     <title>MATLAB to Eigen</title>
     <style type="text/css">
 table
@@ -204,6 +203,30 @@ tr.gotcha2 td
         </td>
       </tr>
 
+      <tr class=d1>
+        <td><pre><code>O = ones(m,n)</code></pre></td>
+        <td><pre><code>Matrix* O = Matrix*::Ones(m,n)</code></pre></td>
+        <td></td>
+      </tr>
+
+      <tr class=d0>
+        <td><pre><code>O = zeros(m,n)</code></pre></td>
+        <td><pre><code>Matrix* O = Matrix*::Zero(m,n)</code></pre></td>
+        <td></td>
+      </tr>
+
+      <tr class=d1>
+        <td><pre><code>B = A(I,J)<br>B = A(I,:)</code></pre></td>
+        <td><pre><code>igl::slice(A,I,J,B)<br>B = igl::slice(A,I,igl::colon(0,A.cols()-1))</code></pre></td>
+        <td></td>
+      </tr>
+
+      <tr class=d0>
+        <td><pre><code>B(I,J) = A<br>B(I,:) = A</code></pre></td>
+        <td><pre><code>igl::slice_into(A,I,J,B)<br>B = igl::slice_into(A,I,igl::colon(0,B.cols()-1))</code></pre></td>
+        <td></td>
+      </tr>
+
       <!-- Insert rows for each command pair -->
 
       <!-- Leave this here for copy and pasting

+ 1 - 0
min_quad_with_fixed.h

@@ -58,6 +58,7 @@ namespace igl
 #include <Eigen/SparseExtra>
 #include <cassert>
 #include <cstdio>
+#include <iostream>
 
 #include "slice.h"
 #include "is_symmetric.h"

+ 1 - 0
sparse.h

@@ -87,6 +87,7 @@ inline void igl::sparse(
     dyn_X.coeffRef((int)I(i),(int)J(i)) += (T)V(i);
   }
   X = Eigen::SparseMatrix<T>(dyn_X);
+
 }
 
 #endif

+ 8 - 7
trackball.h

@@ -29,10 +29,11 @@ namespace igl
 
 // Implementation
 
-#include <dot.h>
-#include <cross.h>
-#include <axis_angle_to_quat.h>
-#include <quat_mult.h>
+#include "EPS.h"
+#include "dot.h"
+#include "cross.h"
+#include "axis_angle_to_quat.h"
+#include "quat_mult.h"
 #include <cmath>
 #include <cstdlib>
 #include <algorithm>
@@ -41,7 +42,7 @@ namespace igl
 template <typename Q_type>
 static inline Q_type _QuatD(int w, int h)
 {
-  return (Q_type)std::min(abs(w), abs(h)) - 4;
+  return (Q_type)(abs(w) < abs(h) ? abs(w) : abs(h)) - 4;
 }
 template <typename Q_type>
 static inline Q_type _QuatIX(int x, int w, int h)
@@ -82,7 +83,7 @@ inline void igl::trackball(
   double z = 1;
   double n0 = sqrt(original_x*original_x + original_y*original_y + z*z);
   double n1 = sqrt(x*x + y*y + z*z);
-  if(n0>DOUBLE_EPS && n1>DOUBLE_EPS)
+  if(n0>igl::DOUBLE_EPS && n1>igl::DOUBLE_EPS)
   {
     double v0[] = { original_x/n0, original_y/n0, z/n0 };
     double v1[] = { x/n1, y/n1, z/n1 };
@@ -104,7 +105,7 @@ inline void igl::trackball(
       down_quat[2]*down_quat[2]+
       down_quat[3]*down_quat[3]);
 
-    if( fabs(nqorig)>DOUBLE_EPS_SQ )
+    if( fabs(nqorig)>igl::DOUBLE_EPS_SQ )
     {
         qorig[0] = down_quat[0]/nqorig;
         qorig[1] = down_quat[1]/nqorig;

+ 7 - 5
writeDMAT.h

@@ -1,29 +1,31 @@
 #ifndef IGL_WRITEDMAT_H
 #define IGL_WRITEDMAT_H
 // See writeDMAT.h for a description of the .dmat file type
-#include <Eigen/Core>
 #include <string>
 namespace igl
 {
   // Write a matrix using ascii dmat file type
   //
+  // Template:
+  //   Mat  matrix type that supports .rows(), .cols(), operator(i,j)
   // Inputs:
   //   file_name  path to .dmat file
   //   W  eigen matrix containing to-be-written coefficients
   // Returns true on success, false on error
   //
-  inline bool writeDMAT(const std::string file_name, const Eigen::MatrixXd & W);
+  template <class Mat>
+  inline bool writeDMAT(const std::string file_name, const Mat & W);
 }
 
 // Implementation
 #include <cstdio>
 
-inline bool igl::writeDMAT(const std::string file_name, const Eigen::MatrixXd & W)
+  template <class Mat>
+inline bool igl::writeDMAT(const std::string file_name, const Mat & W)
 {
   FILE * fp = fopen(file_name.c_str(),"w");
   if(fp == NULL)
   {
-    fclose(fp);
     fprintf(stderr,"IOError: writeDMAT() could not open %s...",file_name.c_str());
     return false; 
   }
@@ -35,7 +37,7 @@ inline bool igl::writeDMAT(const std::string file_name, const Eigen::MatrixXd &
     // loop over rows (down columns) quickly
     for(int i = 0;i < W.rows();i++)
     {
-      fprintf(fp,"%lg\n",W(i,j));
+      fprintf(fp,"%lg\n",(double)W(i,j));
     }
   }
   fclose(fp);