Browse Source

better arap example

Former-commit-id: 2249fb0f4d74cdac1b94bd715620eca911d582db
Alec Jacobson 11 years ago
parent
commit
902a1dc534
3 changed files with 23 additions and 21 deletions
  1. 1 0
      README.md
  2. 1 1
      examples/arap/Makefile
  3. 21 20
      examples/arap/example.cpp

+ 1 - 0
README.md

@@ -25,6 +25,7 @@ listed below.
 - Mosek  libiglmosek extra only
 - Matlab  libiglmatlab extra only
 - boost  libiglboost, libiglcgal extra only
+- SSE/AVX  libiglsvd3x3 extra only
 - CGAL  libiglcgal extra only
     * boost 
     * gmp

+ 1 - 1
examples/arap/Makefile

@@ -23,7 +23,7 @@ EMBREE_LIB=-L$(EMBREE)/build -lembree -lsys
 
 # YIMAGE Library
 YIMG=$(LIBIGL)/external/yimg/
-YIMG_LIB=-L$(YIMG) -lyimg -lz -L/usr/X11/lib -lpng -bind_at_load
+YIMG_LIB=-L$(YIMG) -lyimg -lz -L/opt/local/lib -lpng -bind_at_load
 YIMG_INC=-I/usr/X11/include -I$(YIMG)
 
 ANTTWEAKBAR_INC=-I$(LIBIGL)/external/AntTweakBar/include

+ 21 - 20
examples/arap/example.cpp

@@ -141,8 +141,6 @@ double bbd;
 int tot_num_samples = 0;
 #define REBAR_NAME "temp.rbr"
 igl::ReTwBar rebar; // Pointer to the tweak bar
-bool flip_y = false;
-bool rotate_xy = false;
 
 int num_in_selection(const Eigen::VectorXi & S)
 {
@@ -176,12 +174,17 @@ bool init_arap()
         b(bi) = v;
         bc(bi,S(v)) = 1;
         bi++;
-        if(S(v) == 0)
-        {
-          C.row(v) = RowVector3d(0.039,0.31,1);
-        }else
+        switch(S(v))
         {
-          C.row(v) = RowVector3d(1,0.41,0.70);
+          case 0:
+            C.row(v) = RowVector3d(0.039,0.31,1);
+            break;
+          case 1:
+            C.row(v) = RowVector3d(1,0.41,0.70);
+            break;
+          default:
+            C.row(v) = RowVector3d(0.4,0.8,0.3);
+            break;
         }
       }else
       {
@@ -223,25 +226,25 @@ bool update_arap()
         {
           case 0:
           {
-            //const double r = mid(0)*0.25;
-            //bc(bi,0) += r*cos(0.5*get_seconds()*2.*PI);
-            //bc(bi,1) -= r+r*sin(0.5*get_seconds()*2.*PI);
+            const double r = mid(0)*0.25;
+            bc(bi,0) += r*cos(0.5*get_seconds()*2.*PI);
+            bc(bi,1) -= r+r*sin(0.5*get_seconds()*2.*PI);
             break;
           }
           case 1:
           {
-            //const double r = mid(1)*0.15;
-            //bc(bi,1) += r+r*cos(0.15*get_seconds()*2.*PI);
-            //bc(bi,2) -= r*sin(0.15*get_seconds()*2.*PI);
+            const double r = mid(1)*0.15;
+            bc(bi,1) += r+r*cos(0.15*get_seconds()*2.*PI);
+            bc(bi,2) -= r*sin(0.15*get_seconds()*2.*PI);
 
             //// Pull-up
             //bc(bi,0) += 0.42;//mid(0)*0.5;
             //bc(bi,1) += 0.55;//mid(0)*0.5;
-            // Bend
-            Vector3d t(-1,0,0);
-            Quaterniond q(AngleAxisd(PI/1.5,Vector3d(0,1.0,0.1).normalized()));
-            const Vector3d a = bc.row(bi);
-            bc.row(bi) = (q*(a-t) + t) + Vector3d(1.5,0.1,0.9);
+            //// Bend
+            //Vector3d t(-1,0,0);
+            //Quaterniond q(AngleAxisd(PI/1.5,Vector3d(0,1.0,0.1).normalized()));
+            //const Vector3d a = bc.row(bi);
+            //bc.row(bi) = (q*(a-t) + t) + Vector3d(1.5,0.1,0.9);
                 
 
             break;
@@ -660,8 +663,6 @@ int main(int argc, char * argv[])
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  rebar.TwAddVarRW("flip_y", TW_TYPE_BOOLCPP, &flip_y,"key=f");
-  rebar.TwAddVarRW("rotate_xy", TW_TYPE_BOOLCPP, &rotate_xy,"key=r");
   rebar.load(REBAR_NAME);
 
   glutInitDisplayString( "rgba depth double samples>=8 ");