Package net.phys2d.math

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


    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);
   
    bias = new Vector2f(dp);
    bias.scale(-0.1f);
    bias.scale(invDT);
View Full Code Here


   * Apply the impulse caused by the joint to the bodies attached.
   */
  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) {
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

   * @see net.phys2d.raw.Joint#applyImpulse()
   */
  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));

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

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));

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

    Vector2f impulse = new Vector2f(dp);
View Full Code Here

    {
      Contact c = contacts[i];
      c.normal.normalise();
     
      Vector2f r1 = new Vector2f(c.position);
      r1.sub(body1.getPosition());
      Vector2f r2 = new Vector2f(c.position);
      r2.sub(body2.getPosition());

      // Precompute normal mass, tangent mass, and bias.
      float rn1 = r1.dot(c.normal);
View Full Code Here

      c.normal.normalise();
     
      Vector2f r1 = new Vector2f(c.position);
      r1.sub(body1.getPosition());
      Vector2f r2 = new Vector2f(c.position);
      r2.sub(body2.getPosition());

      // Precompute normal mass, tangent mass, and bias.
      float rn1 = r1.dot(c.normal);
      float rn2 = r2.dot(c.normal);
      float kNormal = body1.getInvMass() + body2.getInvMass();
View Full Code Here

      // Compute restitution
      // Relative velocity at contact
      Vector2f relativeVelocity =  new Vector2f(body2.getVelocity());
      relativeVelocity.add(MathUtil.cross(r2, body2.getAngularVelocity()));
      relativeVelocity.sub(body1.getVelocity());
      relativeVelocity.sub(MathUtil.cross(r1, body1.getAngularVelocity()));
     
      float combinedRestitution = (body1.getRestitution() * body2.getRestitution());
      float relVel = c.normal.dot(relativeVelocity);
      c.restitution = combinedRestitution * -relVel;
 
View Full Code Here

      // Compute restitution
      // Relative velocity at contact
      Vector2f relativeVelocity =  new Vector2f(body2.getVelocity());
      relativeVelocity.add(MathUtil.cross(r2, body2.getAngularVelocity()));
      relativeVelocity.sub(body1.getVelocity());
      relativeVelocity.sub(MathUtil.cross(r1, body1.getAngularVelocity()));
     
      float combinedRestitution = (body1.getRestitution() * body2.getRestitution());
      float relVel = c.normal.dot(relativeVelocity);
      c.restitution = combinedRestitution * -relVel;
      c.restitution = Math.max(c.restitution, 0);
View Full Code Here

    for (int i = 0; i < numContacts; ++i)
    {
      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());
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.