Examples of NCPConstraint


Examples of jinngine.physics.solver.Solver.NCPConstraint

    Solver s = new ConjugateGradients();
   
    Body b1 = new Body("default");
    Body b2 = new Body("default");
   
    Solver.NCPConstraint c1 = new NCPConstraint();
    Vector3 va =new Vector3(1,0,0);
    Vector3 vb =new Vector3(-1,0,0);
    Vector3 z = new Vector3(0,0,0);
    c1.assign(b1,b2,
        va,z,vb,z,
        va,z,vb,z,
        -Double.POSITIVE_INFINITY,Double.POSITIVE_INFINITY,null,1, 0);
   
    //This is the system
View Full Code Here

Examples of jinngine.physics.solver.Solver.NCPConstraint

   
    Solver s = new ConjugateGradients();
    Body b1 = new Body("default");
    Body b2 = new Body("default");
   
    Solver.NCPConstraint c1 = new NCPConstraint();
    Solver.NCPConstraint c2 = new NCPConstraint();

    Vector3 va =new Vector3(1,0,0);
    Vector3 vb =new Vector3(-1,0,0);
    Vector3 z = new Vector3(0,0,0);
    c1.assign(b1,b2,
        va,z,vb,z,
        va,z,vb,z,
        0,0,null,1, 0);
    c2.assign(b1,b2,
        va,z,vb,z,
        va,z,vb,z,
        0,0,null,1, 0);

   
View Full Code Here

Examples of jinngine.physics.solver.Solver.NCPConstraint

    correction = correction * 0.9;
   
    //correction=correction>0?0:correction;

    // the normal constraint
    final NCPConstraint c = new NCPConstraint();
    c.assign(b1,b2,
        nB1, nB2, nB3, nB4,
        nJ1, nJ2, nJ3, nJ4,
        lowerNormalLimit, Double.POSITIVE_INFINITY,
        null,
           -(unf-uni)-correction, -correction) ;
   
    // set distance (unused in simulator)
    c.distance = cp.distance;
   
    //normal-friction coupling
    final NCPConstraint coupling = enableCoupling?c:null;
   
    //set the correct friction setting for this contact
    c.mu = cp.friction;
           
    //first tangent
    final Vector3 t2J1 = t2;
    final Vector3 t2J2 = r1.cross(t2);
    final Vector3 t2J3 = t2.negate();
    final Vector3 t2J4 = r2.cross(t2).negate();
    final Vector3 t2B1 = b1.isFixed()? new Vector3(): M1.multiply(t2J1);
    final Vector3 t2B2 = b1.isFixed()new Vector3(): I1.multiply(t2J2);
    final Vector3 t2B3 = b2.isFixed()? new Vector3(): M2.multiply(t2J3);
    final Vector3 t2B4 = b2.isFixed()? new Vector3(): I2.multiply(t2J4);

    //then the tangential friction constraints
    double ut1i = t2J1.dot(b1.state.velocity) + t2J2.dot(b1.state.omega) + t2J3.dot(b2.state.velocity) + t2J4.dot(b2.state.omega); //relativeVelocity(b1,b2,p,t2);
    double ut1f = 0;
   
    //double t2Fext = t2B1.dot(b1.state.FCm) + t2B2.dot(b1.state.tauCm) + t2B3.dot(b2.state.FCm) + t2B4.dot(b2.state.tauCm);
    final NCPConstraint c2 = new NCPConstraint();
    c2.assign(b1,b2,
        t2B1, t2B2,  t2B3, t2B4,       
        t2J1, t2J2, t2J3, t2J4,
        -frictionBoundMagnitude, frictionBoundMagnitude,
        coupling,
        -(ut1f-ut1i),
        0
    );
   
    //second tangent
    final Vector3 t3J1 = t3;
    final Vector3 t3J2 = r1.cross(t3);
    final Vector3 t3J3 = t3.negate();
    final Vector3 t3J4 = r2.cross(t3).negate();
    final Vector3 t3B1 = b1.isFixed()? new Vector3(): M1.multiply(t3J1);
    final Vector3 t3B2 = b1.isFixed()? new Vector3(): I1.multiply(t3J2);
    final Vector3 t3B3 = b2.isFixed()? new Vector3(): M2.multiply(t3J3);
    final Vector3 t3B4 = b2.isFixed()? new Vector3(): I2.multiply(t3J4);

    double ut2i = t3J1.dot(b1.state.velocity) + t3J2.dot(b1.state.omega) + t3J3.dot(b2.state.velocity) + t3J4.dot(b2.state.omega); //relativeVelocity(b1,b2,p,t2);
    double ut2f = 0;
   
    final NCPConstraint c3 = new NCPConstraint();
    c3.assign(b1,b2,
        t3B1, t3B2,  t3B3, t3B4,
        t3J1, t3J2, t3J3, t3J4,
        -frictionBoundMagnitude, frictionBoundMagnitude,
        coupling,
        -(ut2f-ut2i),
View Full Code Here

Examples of jinngine.physics.solver.Solver.NCPConstraint

      numberOfNcpConstraints = 0;

      // sum up the applied contact force
      Iterator<NCPConstraint> ncps = constraint.getNcpConstraints();
      while(ncps.hasNext()) {
        NCPConstraint ncp = ncps.next();
        totalforce += ncp.lambda;     
        numberOfNcpConstraints += 1;
      }

      // check condition
      if (totalforce > impulsethreshold) { 
       
        // move constraint to triggered list
        monitored.remove();
        triggeredconstraints.add(constraint);
       
        // perform trigger event callback
        Pair<Body> bodies =  constraint.getBodies();
        Body interacting = bodies.getFirst()==body? bodies.getSecond(): bodies.getFirst();
        callback.contactAboveThreshold(interacting, constraint);

      } // if force > forcethreshold
    } // for monitored constraints 
   
    // see if triggered constraints should be moved back to monitored
    ListIterator<ContactConstraint> triggered = triggeredconstraints.listIterator();
    while ( triggered.hasNext()) {

      ContactConstraint constraint = triggered.next();
      totalforce = 0;
      numberOfNcpConstraints = 0;

      // sum up the applied contact force
      Iterator<NCPConstraint> ncps = constraint.getNcpConstraints();
      while(ncps.hasNext()) {
        NCPConstraint ncp = ncps.next();
        totalforce += ncp.lambda;       
        numberOfNcpConstraints += 1;
      }

      // check condition
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.