Examples of sub()


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

    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

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

    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

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

      // 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

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

   * @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

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

    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

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

    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

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

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

   * 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

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

   */
  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

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

   * @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
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.