Package net.phys2d.math

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


      body1.adjustAngularVelocity((body1.getInvI() * MathUtil.cross(R,
          impulse)));
    }
    if (!body2.isStatic()) {
      Vector2f accum2 = new Vector2f(impulse);
      accum2.scale(-body2.getInvMass());
      body2.adjustVelocity(accum2);
      body2.adjustAngularVelocity(-(body2.getInvI() * MathUtil.cross(r2,
          impulse)));
    }
  }
 
View Full Code Here


    // Apply accumulated impulse.
    accumulatedImpulse.scale(relaxation);
   
    if (!body1.isStatic()) {
      Vector2f accum1 = new Vector2f(accumulatedImpulse);
      accum1.scale(-body1.getInvMass());
      body1.adjustVelocity(accum1);
      body1.adjustAngularVelocity(-(body1.getInvI() * MathUtil.cross(r1, accumulatedImpulse)));
    }

    if (!body2.isStatic()) {
View Full Code Here

      body1.adjustAngularVelocity(-(body1.getInvI() * MathUtil.cross(r1, accumulatedImpulse)));
    }

    if (!body2.isStatic()) {
      Vector2f accum2 = new Vector2f(accumulatedImpulse);
      accum2.scale(body2.getInvMass());
      body2.adjustVelocity(accum2);
      body2.adjustAngularVelocity(body2.getInvI() * MathUtil.cross(r2, accumulatedImpulse));
    }
  }
 
View Full Code Here

  public void applyImpulse() {
    Vector2f dv = new Vector2f(body2.getVelocity());
    dv.add(MathUtil.cross(body2.getAngularVelocity(),r2));
    dv.sub(body1.getVelocity());
    dv.sub(MathUtil.cross(body1.getAngularVelocity(),r1));
      dv.scale(-1);
      dv.add(bias); // TODO: is this baumgarte stabilization?
     
      if (dv.lengthSquared() == 0) {
        return;
      }
View Full Code Here

     
    Vector2f impulse = MathUtil.mul(M, dv);

    if (!body1.isStatic()) {
      Vector2f delta1 = new Vector2f(impulse);
      delta1.scale(-body1.getInvMass());
      body1.adjustVelocity(delta1);
      body1.adjustAngularVelocity(-body1.getInvI() * MathUtil.cross(r1,impulse));
    }

    if (!body2.isStatic()) {
View Full Code Here

      body1.adjustAngularVelocity(-body1.getInvI() * MathUtil.cross(r1,impulse));
    }

    if (!body2.isStatic()) {
      Vector2f delta2 = new Vector2f(impulse);
      delta2.scale(body2.getInvMass());
      body2.adjustVelocity(delta2);
      body2.adjustAngularVelocity(body2.getInvI() * MathUtil.cross(r2,impulse));
    }
   
    accumulatedImpulse.add(impulse);
 
View Full Code Here

    float ju = -dv.dot(dp) + bias;
    float p = ju / sc;

    Vector2f impulse = new Vector2f(dp);
    impulse.scale(p);

    if (!body1.isStatic()) {
      Vector2f accum1 = new Vector2f(impulse);
      accum1.scale(-body1.getInvMass());
      body1.adjustVelocity(accum1);
View Full Code Here

    Vector2f impulse = new Vector2f(dp);
    impulse.scale(p);

    if (!body1.isStatic()) {
      Vector2f accum1 = new Vector2f(impulse);
      accum1.scale(-body1.getInvMass());
      body1.adjustVelocity(accum1);
      body1.adjustAngularVelocity(-(body1.getInvI() * MathUtil.cross(r1,
          impulse)));
    }

 
View Full Code Here

          impulse)));
    }

    if (!body2.isStatic()) {
      Vector2f accum2 = new Vector2f(impulse);
      accum2.scale(body2.getInvMass());
      body2.adjustVelocity(accum2);
      body2.adjustAngularVelocity(body2.getInvI()
          * MathUtil.cross(r2, impulse));
    }

View Full Code Here

    dp.normalise();

    sc = MathUtil.mul(K, dp).dot(dp);

    Vector2f impulse = new Vector2f(dp);
    impulse.scale(accumulatedImpulse);

    if (!body1.isStatic()) {
      Vector2f accum1 = new Vector2f(impulse);
      accum1.scale(-body1.getInvMass());
      body1.adjustVelocity(accum1);
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.