Răsfoiți Sursa

Template winding_number() to hopefully work with gmpq.

But it is not working yet, gmpq number does not support sqrt()...


Former-commit-id: a2a468ed7ee7f17f34aa7830690133067eee2738
Qingnan Zhou 10 ani în urmă
părinte
comite
5b31a356f9
2 a modificat fișierele cu 14 adăugiri și 14 ștergeri
  1. 10 10
      include/igl/winding_number.cpp
  2. 4 4
      include/igl/winding_number.h

+ 10 - 10
include/igl/winding_number.cpp

@@ -43,15 +43,15 @@ IGL_INLINE void igl::winding_number(
   }
 }
 
-template <typename DerivedF>
+template <typename Scalar, typename DerivedF>
 IGL_INLINE void igl::winding_number_3(
-  const double * V,
+  const Scalar * V,
   const int n,
   const DerivedF * F,
   const int m,
-  const double * O,
+  const Scalar * O,
   const int no,
-  double * S)
+  Scalar * S)
 {
   // Initialize output
   // loop over origins
@@ -68,7 +68,7 @@ IGL_INLINE void igl::winding_number_3(
   for(int f = 0;f<m;f++)
   {
     // Gather corners 
-    double C[3][3];
+    Scalar C[3][3];
     // loop around triangle
     for(int t=0;t<3;t++)
     {
@@ -84,8 +84,8 @@ IGL_INLINE void igl::winding_number_3(
     for(int o = 0;o<no;o++)
     {
       // Gather vectors to corners
-      double v[3][3];
-      double vl[3];
+      Scalar v[3][3];
+      Scalar vl[3];
       // loop around triangle
       for(int t=0;t<3;t++)
       {
@@ -106,7 +106,7 @@ IGL_INLINE void igl::winding_number_3(
       }
       //printf("\n");
       // Compute determinant
-      double detf = 
+      Scalar detf = 
         v[0][0]*v[1][1]*v[2][2]+
         v[1][0]*v[2][1]*v[0][2]+
         v[2][0]*v[0][1]*v[1][2]-
@@ -114,7 +114,7 @@ IGL_INLINE void igl::winding_number_3(
         v[1][0]*v[0][1]*v[2][2]-
         v[0][0]*v[2][1]*v[1][2];
       // Compute pairwise dotproducts
-      double dp[3];
+      Scalar dp[3];
       dp[0] = v[1][0]*v[2][0];
       dp[0] += v[1][1]*v[2][1];
       dp[0] += v[1][2]*v[2][2];
@@ -126,7 +126,7 @@ IGL_INLINE void igl::winding_number_3(
       dp[2] += v[0][2]*v[1][2];
       // Compute winding number
       // Only divide by TWO_PI instead of 4*pi because there was a 2 out front
-      double val = atan2(detf,
+      Scalar val = atan2(detf,
         vl[0]*vl[1]*vl[2] + 
         dp[0]*vl[0] +
         dp[1]*vl[1] +

+ 4 - 4
include/igl/winding_number.h

@@ -39,15 +39,15 @@ namespace igl
   //   no  number of origins
   // Outputs:
   //   S  no by 1 list of winding numbers
-  template <typename DerivedF>
+  template <typename Scalar, typename DerivedF>
   IGL_INLINE void winding_number_3(
-    const double * V,
+    const Scalar * V,
     const int n,
     const DerivedF * F,
     const int m,
-    const double * O,
+    const Scalar * O,
     const int no,
-    double * S);
+    Scalar * S);
   //// Only one evaluation origin
   //template <typename DerivedF>
   //IGL_INLINE void winding_number_3(