Selaa lähdekoodia

cast so that inputs can be float

Former-commit-id: 37d64ad0c1cf3e46ced9d653cd4220feb4f29b90
Alec Jacobson 8 vuotta sitten
vanhempi
commit
36c5ec93f3
3 muutettua tiedostoa jossa 13 lisäystä ja 3 poistoa
  1. 7 1
      include/igl/jet.cpp
  2. 1 1
      include/igl/jet.h
  3. 5 1
      include/igl/parula.cpp

+ 7 - 1
include/igl/jet.cpp

@@ -118,9 +118,15 @@ IGL_INLINE void igl::jet(
   Eigen::PlainObjectBase<DerivedC> & C)
 {
   C.resize(Z.rows(),3);
+  double denom = (max_z-min_z);
+  denom = denom==0?1:denom;
   for(int r = 0;r<Z.rows();r++)
   {
-    jet((-min_z+Z(r,0))/(max_z-min_z),C(r,0),C(r,1),C(r,2));
+    jet(
+      (typename DerivedC::Scalar)((-min_z+Z(r,0))/denom),
+      C(r,0),
+      C(r,1),
+      C(r,2));
   }
 }
 

+ 1 - 1
include/igl/jet.h

@@ -37,7 +37,7 @@ namespace igl
   template <typename T>
   IGL_INLINE void jet(const T f, T & r, T & g, T & b);
   // Inputs:
-  //   Z  #Z list of factos 
+  //   Z  #Z list of factors
   //   normalize  whether to normalize Z to be tightly between [0,1]
   // Outputs:
   //   C  #C by 3 list of rgb colors

+ 5 - 1
include/igl/parula.cpp

@@ -57,7 +57,11 @@ IGL_INLINE void igl::parula(
   denom = denom==0?1:denom;
   for(int r = 0;r<Z.rows();r++)
   {
-    parula((-min_z+Z(r,0))/denom,C(r,0),C(r,1),C(r,2));
+    parula(
+      (typename DerivedC::Scalar)((-min_z+Z(r,0))/denom),
+      C(r,0),
+      C(r,1),
+      C(r,2));
   }
 }