Package net.phys2d.math

Examples of net.phys2d.math.Vector2f.sub()


      Contact c = contacts[i];
     
      Vector2f r1 = new Vector2f(c.position);
      r1.sub(b1.getPosition());
      Vector2f r2 = new Vector2f(c.position);
      r2.sub(b2.getPosition());

      // Relative velocity at contact
      Vector2f relativeVelocity =  new Vector2f(b2.getVelocity());
      relativeVelocity.add(MathUtil.cross(b2.getAngularVelocity(), r2));
      relativeVelocity.sub(b1.getVelocity());
View Full Code Here


      r2.sub(b2.getPosition());

      // Relative velocity at contact
      Vector2f relativeVelocity =  new Vector2f(b2.getVelocity());
      relativeVelocity.add(MathUtil.cross(b2.getAngularVelocity(), r2));
      relativeVelocity.sub(b1.getVelocity());
      relativeVelocity.sub(MathUtil.cross(b1.getAngularVelocity(), r1));
     
      // Compute normal impulse with bias.
      float vn = relativeVelocity.dot(c.normal);
     
View Full Code Here

      // Relative velocity at contact
      Vector2f relativeVelocity =  new Vector2f(b2.getVelocity());
      relativeVelocity.add(MathUtil.cross(b2.getAngularVelocity(), r2));
      relativeVelocity.sub(b1.getVelocity());
      relativeVelocity.sub(MathUtil.cross(b1.getAngularVelocity(), r1));
     
      // Compute normal impulse with bias.
      float vn = relativeVelocity.dot(c.normal);
     
      // bias caculations are now handled seperately hence we only
View Full Code Here

    Vector2f p1 = new Vector2f(body1.getPosition());
    p1.add(r1);
    Vector2f p2 = new Vector2f(body2.getPosition());
    p2.add(r2);
    Vector2f dp = new Vector2f(p2);
    dp.sub(p1);
    float length = dp.length();
    // dp.scale(1.0f/length);
    Vector2f V = new Vector2f((float) Math.cos(originalAngle
        + body1.getRotation()), (float) Math.sin(originalAngle
        + body1.getRotation()));
View Full Code Here

    if(collideSide==COLLIDE_NONE)
      return;
   
    Vector2f dv = new Vector2f(body2.getVelocity());
    dv.add(MathUtil.cross(body2.getAngularVelocity(),r2));
    dv.sub(body1.getVelocity());
    dv.sub(MathUtil.cross(body1.getAngularVelocity(),r1));
    float reln = dv.dot(ndp);
    reln = restitute-reln;
    float P = reln/K;
    float newImpulse;
View Full Code Here

      return;
   
    Vector2f dv = new Vector2f(body2.getVelocity());
    dv.add(MathUtil.cross(body2.getAngularVelocity(),r2));
    dv.sub(body1.getVelocity());
    dv.sub(MathUtil.cross(body1.getAngularVelocity(),r1));
    float reln = dv.dot(ndp);
    reln = restitute-reln;
    float P = reln/K;
    float newImpulse;
    if(collideSide==COLLIDE_MIN){
View Full Code Here

    Vector2f p1 = new Vector2f(body1.getPosition());
    p1.add(r1);
    Vector2f p2 = new Vector2f(body2.getPosition());
    p2.add(r2);
    Vector2f dp = new Vector2f(p2);
    dp.sub(p1);
   
    Vector2f dv = new Vector2f(body2.getVelocity());
    dv.add(MathUtil.cross(body2.getAngularVelocity(),r2));
    dv.sub(body1.getVelocity());
    dv.sub(MathUtil.cross(body1.getAngularVelocity(),r1));
View Full Code Here

    Vector2f dp = new Vector2f(p2);
    dp.sub(p1);
   
    Vector2f dv = new Vector2f(body2.getVelocity());
    dv.add(MathUtil.cross(body2.getAngularVelocity(),r2));
    dv.sub(body1.getVelocity());
    dv.sub(MathUtil.cross(body1.getAngularVelocity(),r1));
     
    ndp = new Vector2f(dp);
    ndp.normalise();
   
View Full Code Here

    dp.sub(p1);
   
    Vector2f dv = new Vector2f(body2.getVelocity());
    dv.add(MathUtil.cross(body2.getAngularVelocity(),r2));
    dv.sub(body1.getVelocity());
    dv.sub(MathUtil.cross(body1.getAngularVelocity(),r1));
     
    ndp = new Vector2f(dp);
    ndp.normalise();
   
    restitute = -restitutionConstant*dv.dot(ndp);
 
View Full Code Here

    Vector2f v;
    int m = -1;
   
    for ( int i = 0; i < vertices.length; i++ ) {
      v = new Vector2f(vertices[i]);
      v.sub(p);
      l = v.x * v.x + v.y * v.y;
     
      if ( l < r ) {
        r = l;
        m = i;
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.