Package net.phys2d.math

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


    R = new Vector2f(r1);
    R.add(dp);
    // System.out.println(accumulateImpulse);
    Vector2f relativeVelocity = new Vector2f(body2.getVelocity());
    relativeVelocity.add(MathUtil.cross(r2, body2.getAngularVelocity()));
    relativeVelocity.sub(body1.getVelocity());
    relativeVelocity.sub(MathUtil.cross(r1, body1.getAngularVelocity()));

    /*
     * Matrix2f tr1 = new Matrix2f(-body1.getRotation()); relativeVelocity =
     * MathUtil.mul(tr1, relativeVelocity);
View Full Code Here


    R.add(dp);
    // System.out.println(accumulateImpulse);
    Vector2f relativeVelocity = new Vector2f(body2.getVelocity());
    relativeVelocity.add(MathUtil.cross(r2, body2.getAngularVelocity()));
    relativeVelocity.sub(body1.getVelocity());
    relativeVelocity.sub(MathUtil.cross(r1, body1.getAngularVelocity()));

    /*
     * Matrix2f tr1 = new Matrix2f(-body1.getRotation()); relativeVelocity =
     * MathUtil.mul(tr1, relativeVelocity);
     * relativeVelocity.add(MathUtil.mul(tr1, dp));
View Full Code Here

    stretchedSpringConst = 100;
    compressedSpringConst = 100;
    brokenSpringConst = 100;
   
    Vector2f spring = new Vector2f(anchor1);
    spring.sub(anchor2);
    springSize = spring.length();
    minSpringSize = 0;
    maxSpringSize = 2 * springSize;
   
    set(b1,b2,anchor1,anchor2);
 
View Full Code Here

    body2 = b2; 

    Matrix2f rot1 = new Matrix2f(body1.getRotation());
    Matrix2f rot1T = rot1.transpose();
    Vector2f a1 = new Vector2f(anchor1);
    a1.sub(body1.getPosition());
    localAnchor1 = MathUtil.mul(rot1T,a1);
   
    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Matrix2f rot2T = rot2.transpose();
    Vector2f a2 = new Vector2f(anchor2);
View Full Code Here

    localAnchor1 = MathUtil.mul(rot1T,a1);
   
    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Matrix2f rot2T = rot2.transpose();
    Vector2f a2 = new Vector2f(anchor2);
    a2.sub(body2.getPosition());
    localAnchor2 = MathUtil.mul(rot2T,a2);
  }

  /**
   * Precaculate everything and apply initial impulse before the
View Full Code Here

    if ( isBroken ) {
      // calculate difference in velocity
      // TODO: share this code with BasicJoint and Arbiter
      Vector2f relativeVelocity =  new Vector2f(body2.getVelocity());
      relativeVelocity.add(MathUtil.cross(body2.getAngularVelocity(), r2));
      relativeVelocity.sub(body1.getVelocity());
      relativeVelocity.sub(MathUtil.cross(body1.getAngularVelocity(), r1));
     
      // project the relative velocity onto the spring vector and apply the mass normal
      float normalImpulse = massNormal * relativeVelocity.dot(spring);
     
 
View Full Code Here

      // calculate difference in velocity
      // TODO: share this code with BasicJoint and Arbiter
      Vector2f relativeVelocity =  new Vector2f(body2.getVelocity());
      relativeVelocity.add(MathUtil.cross(body2.getAngularVelocity(), r2));
      relativeVelocity.sub(body1.getVelocity());
      relativeVelocity.sub(MathUtil.cross(body1.getAngularVelocity(), r1));
     
      // project the relative velocity onto the spring vector and apply the mass normal
      float normalImpulse = massNormal * relativeVelocity.dot(spring);
     
//      // TODO: Clamp the accumulated impulse?
View Full Code Here

   * @return True if the joint is holding the bodies together
   */
  public boolean isActive() {
    if (body1.getPosition().distanceSquared(body2.getPosition()) < distance) {
      Vector2f to2 = new Vector2f(body2.getPosition());
      to2.sub(body1.getPosition());
      to2.normalise();
      Vector2f vel = new Vector2f(body1.getVelocity());
      vel.normalise();
      if (body1.getVelocity().dot(to2) < 0) {
        return true;
View Full Code Here

    Matrix2f rot2 = new Matrix2f(body2.getRotation());
    Matrix2f rot1T = rot1.transpose();
    Matrix2f rot2T = rot2.transpose();

    Vector2f a1 = new Vector2f(anchor);
    a1.sub(body1.getPosition());
    localAnchor1 = MathUtil.mul(rot1T,a1);
    Vector2f a2 = new Vector2f(anchor);
    a2.sub(body2.getPosition());
    localAnchor2 = MathUtil.mul(rot2T,a2);
View Full Code Here

    Vector2f a1 = new Vector2f(anchor);
    a1.sub(body1.getPosition());
    localAnchor1 = MathUtil.mul(rot1T,a1);
    Vector2f a2 = new Vector2f(anchor);
    a2.sub(body2.getPosition());
    localAnchor2 = MathUtil.mul(rot2T,a2);

    accumulatedImpulse.set(0.0f, 0.0f);
    relaxation = 1.0f;
  }
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.