Przeglądaj źródła

normalize rows disambiguation

Former-commit-id: 78409eb4467e0665ec6569b62abe5e02ecc53e41
jalec 13 lat temu
rodzic
commit
20641d7778

+ 0 - 1
examples/Core/Makefile

@@ -13,7 +13,6 @@ matlab_lib=-L$(MATLAB)/bin/maci64/ -leng -lmx
 
 example1: example1.o
 	g++ $(CFLAGS) -o example1 example1.o -framework OpenGL -framework GLUT $(lib)
-	rm example1.o
 
 example1.o: example1.cpp
 	g++ $(CFLAGS) -c example1.cpp -o example1.o $(inc)

+ 0 - 1
examples/ReAntTweakBar/Makefile

@@ -12,7 +12,6 @@ inc=-I$(igl_lib)/include -I/opt/local/include
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o -framework OpenGL -framework GLUT $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/affine/Makefile

@@ -14,7 +14,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/cat/Makefile

@@ -14,7 +14,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/dmat/Makefile

@@ -14,7 +14,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/eigen-gotchas/Makefile

@@ -14,7 +14,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/file_contents_as_string/Makefile

@@ -13,7 +13,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/get_seconds/Makefile

@@ -13,7 +13,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/glslversion/Makefile

@@ -13,7 +13,6 @@ lib=-framework OpenGL -framework GLUT -L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/glut_speed_test/Makefile

@@ -13,7 +13,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o -framework OpenGL -framework GLUT $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) $(deps) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/is_dir/Makefile

@@ -13,7 +13,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/mode/Makefile

@@ -14,7 +14,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 1 - 2
examples/path_tests/Makefile

@@ -7,13 +7,12 @@ all: example
 
 igl_lib=../../
 
-CFLAGS=-g
+CFLAGS=-g -Wall
 inc=-I$(igl_lib)/include
 lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/pathinfo/Makefile

@@ -13,7 +13,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib) 
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) $(deps) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/slice/Makefile

@@ -15,7 +15,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/sort/Makefile

@@ -14,7 +14,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/stdin_to_temp/Makefile

@@ -13,7 +13,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/trackball/Makefile

@@ -14,7 +14,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o -framework OpenGL -framework GLUT $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) $(deps) -c example.cpp -o example.o $(inc)

+ 0 - 1
examples/transpose_blocks/Makefile

@@ -14,7 +14,6 @@ lib=-L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)
-	rm example.o
 
 example.o: example.cpp
 	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)

+ 2 - 5
include/igl/massmatrix.cpp

@@ -1,5 +1,5 @@
 #include "massmatrix.h"
-#include "normalize_rows.h"
+#include "normalize_row_sums.h"
 #include "sparse.h"
 #include "repmat.h"
 #include <Eigen/Geometry>
@@ -76,10 +76,7 @@ IGL_INLINE void igl::massmatrix(
           cosines.col(2) = 
             (l.col(1).array().pow(2)+l.col(0).array().pow(2)-l.col(2).array().pow(2))/(l.col(0).array()*l.col(1).array()*2.0);
           Matrix<Scalar,Dynamic,3> barycentric = cosines.array() * l.array();
-
-          WRONG NORMALIZE THIS IS L2 NORMALIZE
-
-          //normalize_rows(barycentric,barycentric);
+          normalize_row_sums(barycentric,barycentric);
           cout<<"barycentric=["<<barycentric<<"];"<<endl;
           Matrix<Scalar,Dynamic,3> partial = barycentric;
           partial.col(0).array() *= dblA.array() * 0.5;

+ 23 - 0
include/igl/normalize_row_lengths.cpp

@@ -0,0 +1,23 @@
+#include "normalize_row_lengths.h"
+
+template <typename DerivedV>
+IGL_INLINE void igl::normalize_row_lengths(
+  const Eigen::PlainObjectBase<DerivedV>& A,
+  Eigen::PlainObjectBase<DerivedV> & B)
+{
+  // Resize output
+  B.resize(A.rows(),A.cols());
+
+  // loop over rows
+  for(int i = 0; i < A.rows();i++)
+  {
+    B.row(i) = A.row(i).normalized();
+  }
+}
+#ifndef IGL_HEADER_ONLY
+// Explicit template specialization
+// generated by autoexplicit.sh
+template void igl::normalize_row_lengths<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+template void igl::normalize_row_lengths<Eigen::Matrix<double, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
+template void igl::normalize_row_lengths<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
+#endif

+ 28 - 0
include/igl/normalize_row_lengths.h

@@ -0,0 +1,28 @@
+#ifndef IGL_NORMALIZE_ROW_LENGTHS_H
+#define IGL_NORMALIZE_ROW_LENGTHS_H
+#include "igl_inline.h"
+#include <Eigen/Core>
+
+// History:
+// March 24, 2012: Alec changed function name from normalize_rows to
+//   normalize_row_lengths to avoid confusion with normalize_row_sums
+
+namespace igl
+{
+  // Normalize the rows in A so that their lengths are each 1 and place the new
+  // entries in B
+  // Inputs:
+  //   A  #rows by k input matrix
+  // Outputs:
+  //   B  #rows by k input matrix, can be the same as A
+  template <typename DerivedV>
+  IGL_INLINE void normalize_row_lengths(
+   const Eigen::PlainObjectBase<DerivedV>& A,
+   Eigen::PlainObjectBase<DerivedV> & B);
+}
+
+#ifdef IGL_HEADER_ONLY
+#  include "normalize_row_lengths.cpp"
+#endif
+
+#endif

+ 25 - 0
include/igl/normalize_row_sums.cpp

@@ -0,0 +1,25 @@
+#include "normalize_row_sums.h"
+
+template <typename DerivedV>
+IGL_INLINE void igl::normalize_row_sums(
+  const Eigen::PlainObjectBase<DerivedV>& A,
+  Eigen::PlainObjectBase<DerivedV> & B)
+{
+  // Resize output
+  B.derived().resize(A.rows(),A.cols());
+
+  // loop over rows
+  for(int i = 0; i < A.rows();i++)
+  {
+    typename DerivedV::Scalar sum = A.row(i).sum();
+    assert(sum != 0);
+    B.row(i) = A.row(i).array()/sum;
+  }
+}
+#ifndef IGL_HEADER_ONLY
+// Explicit template specialization
+// generated by autoexplicit.sh
+template void igl::normalize_row_sums<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+template void igl::normalize_row_sums<Eigen::Matrix<double, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
+template void igl::normalize_row_sums<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
+#endif

+ 5 - 5
include/igl/normalize_rows.h → include/igl/normalize_row_sums.h

@@ -1,24 +1,24 @@
-#ifndef IGL_NORMALIZE_ROWS_H
-#define IGL_NORMALIZE_ROWS_H
+#ifndef IGL_NORMALIZE_ROW_SUMS_H
+#define IGL_NORMALIZE_ROW_SUMS_H
 #include "igl_inline.h"
 #include <Eigen/Core>
 
 namespace igl
 {
-  // Normalize the rows in A so that their lengths are each 1 and place the new
+  // Normalize the rows in A so that their sums are each 1 and place the new
   // entries in B
   // Inputs:
   //   A  #rows by k input matrix
   // Outputs:
   //   B  #rows by k input matrix, can be the same as A
   template <typename DerivedV>
-  IGL_INLINE void normalize_rows(
+  IGL_INLINE void normalize_row_sums(
    const Eigen::PlainObjectBase<DerivedV>& A,
    Eigen::PlainObjectBase<DerivedV> & B);
 }
 
 #ifdef IGL_HEADER_ONLY
-#  include "normalize_rows.cpp"
+#  include "normalize_row_sums.cpp"
 #endif
 
 #endif

+ 0 - 23
include/igl/normalize_rows.cpp

@@ -1,23 +0,0 @@
-#include "normalize_rows.h"
-
-template <typename DerivedV>
-IGL_INLINE void igl::normalize_rows(
-  const Eigen::PlainObjectBase<DerivedV>& A,
-  Eigen::PlainObjectBase<DerivedV> & B)
-{
-  // Resize output
-  B.resize(A.rows(),A.cols());
-
-  // loop over rows
-  for(int i = 0; i < A.rows();i++)
-  {
-    B.row(i) = A.row(i).normalized();
-  }
-}
-#ifndef IGL_HEADER_ONLY
-// Explicit template specialization
-// generated by autoexplicit.sh
-template void igl::normalize_rows<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
-template void igl::normalize_rows<Eigen::Matrix<double, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
-template void igl::normalize_rows<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
-#endif

+ 3 - 3
include/igl/per_vertex_normals.cpp

@@ -1,7 +1,7 @@
 #include "per_vertex_normals.h"
 
 #include "per_face_normals.h"
-#include "normalize_rows.h"
+#include "normalize_row_lengths.h"
 
 template <typename DerivedV, typename DerivedF>
 IGL_INLINE void igl::per_vertex_normals(
@@ -25,7 +25,7 @@ IGL_INLINE void igl::per_vertex_normals(
     }
   }
   // normalize each row
-  igl::normalize_rows(N,N);
+  igl::normalize_row_lengths(N,N);
 }
 
 template <typename DerivedV, typename DerivedF>
@@ -48,7 +48,7 @@ IGL_INLINE void igl::per_vertex_normals(
     }
   }
   // normalize each row
-  igl::normalize_rows(N,N);
+  igl::normalize_row_lengths(N,N);
 }
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization