vcg-uvic / viper

Open-source code for VIPER -- Volume Invariant Position-based Elastic Rods
Apache License 2.0
903 stars 105 forks source link

Rod setup lacks stretch costraints functionality #16

Closed iqch closed 2 years ago

iqch commented 2 years ago

// CRT

include

using namespace std;

// EIGEN

include <Eigen/Dense>

using Vec2 = Eigen::Vector2f; using Vec3 = Eigen::Vector3f;

// VIPER

include // Se issue #15

int main() { viper::Scene scene;

 scene.setUpDirection(Vec3(0, 1, 0));

 viper::IntArray pIds, rIds;

 int numpt = 3;
 scene.addRod(3, Vec3(0, 0.75, 0), Vec3(1, 0, 0),  0.2, true, pIds, rIds);

 scene.state.xa[pIds[0]] = false;
 scene.state.xai[pIds[0]] = false;

 double T = 0;
 double dt = 0.1;

 cout << "T: " << T << " [ ";
 for (auto e : scene.state.x)
     cout << "(" << e[0] << "," << e[1] << "," << e[2] << "),";
 cout << "]" << endl;

 for (int t = 0; t <5; t++)
 {
    scene.step(dt, 20, true);
    T += dt;

     cout << "T: " << T << " [ ";
     for (auto e : scene.state.x) cout << "(" << e[0] << "," << e[1] << "," << e[2] << "),";
     cout << "]" << endl;
 };

 return 0;

}

Plays fine. but stretching constraints did not work.

T: 0 [ (0,0.75,0),(1,0.75,0),(2,0.75,0),] T: 0.1 [ (0,0.75,0),(1,0.65001,0),(2,0.65001,0),] T: 0.2 [ (0,0.75,0),(1,0.45004,0),(2,0.45004,0),] T: 0.3 [ (0,0.75,0),(1,0.1501,0),(2,0.1501,0),] T: 0.4 [ (0,0.75,0),(1,-0.2498,0),(2,-0.2498,0),] T: 0.5 [ (0,0.75,0),(1,-0.74965,0),(2,-0.74965,0),]

X-coordinate does not change, it look like stretching has no limiting.

iqch commented 2 years ago

Even after ALMOST non-intrusive compiling and building - I've got this functionality https://youtu.be/rVMfXrkgTCg It looks like non-functioning constraints, which is core if this technology