Package net.phys2d.math

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


      p2 = new Vector2f(p1);
      p2.add(new Vector2f(chains * 20, 0));
    }

    final Vector2f direction = new Vector2f(p2);
    direction.sub(p1);
    direction.normalise();
    direction.scale(20);

    final Body bodies[] = new Body[N];
    final Vector2f pos = new Vector2f(p1);
View Full Code Here


      ROVector2f x2 = b2.getPosition();
      Vector2f p2 = MathUtil.mul(R2,joint.getAnchor2());
      p2.add(x2);
     
      Vector2f im = new Vector2f(p2);
      im.sub(p1);
      im.normalise();
     
     
     
      g.setColor(Color.red);
View Full Code Here

    Vector2f endA = vertsA[(intersection.edgeA + 1) % vertsA.length];
    Vector2f startB = vertsB[intersection.edgeB];
    Vector2f endB = vertsB[(intersection.edgeB + 1) % vertsB.length];
   
    Vector2f normal = MathUtil.getNormal(startA, endA);
    normal.sub(MathUtil.getNormal(startB, endB));
    normal.normalise();
   
    contact.setNormal(normal);
    contact.setSeparation(0);
    contact.setFeature(new FeaturePair(intersection.edgeA, intersection.edgeB, 0, 0));
View Full Code Here

   * the edge between vertsA[r[x][0]] and vertsA[r[x][0] + 1]
   * overlaps with vertsB[r[x][1]] and vertsB[r[x][1] + 1].
   */
  public int[][] getCollisionCandidates(Vector2f[] vertsA, Vector2f[] vertsB, Vector2f sweepDirStart, Vector2f sweepDirEnd) {
    Vector2f sweepDir = new Vector2f(sweepDirEnd);
    sweepDir.sub(sweepDirStart);
   
    return getCollisionCandidates(new EdgeSweep(sweepDir), vertsA, vertsB);
  }
}
View Full Code Here

    Matrix2f absC = MathUtil.abs(C);
    Matrix2f absCT = absC.transpose();

    // Box A faces
    Vector2f faceA = MathUtil.abs(dA);
    faceA.sub(hA);
    faceA.sub(MathUtil.mul(absC,hB));
   
    if (faceA.x > 0.0f || faceA.y > 0.0f) {
      return 0;
    }
View Full Code Here

    Matrix2f absCT = absC.transpose();

    // Box A faces
    Vector2f faceA = MathUtil.abs(dA);
    faceA.sub(hA);
    faceA.sub(MathUtil.mul(absC,hB));
   
    if (faceA.x > 0.0f || faceA.y > 0.0f) {
      return 0;
    }
View Full Code Here

      return 0;
    }

    // Box B faces
    Vector2f faceB = MathUtil.abs(dB);
    faceB.sub(MathUtil.mul(absCT,hA));
    faceB.sub(hB);
    //MathUtil.sub(MathUtil.sub(MathUtil.abs(dB),MathUtil.mul(absCT,hA)),hB);
    if (faceB.x > 0.0f || faceB.y > 0.0f) {
      return 0;
    }
View Full Code Here

    }

    // Box B faces
    Vector2f faceB = MathUtil.abs(dB);
    faceB.sub(MathUtil.mul(absCT,hA));
    faceB.sub(hB);
    //MathUtil.sub(MathUtil.sub(MathUtil.abs(dB),MathUtil.mul(absCT,hA)),hB);
    if (faceB.x > 0.0f || faceB.y > 0.0f) {
      return 0;
    }
View Full Code Here

      vertsA[1] = tmp;
    }
   
    // we use the line's normal for our sweepline projection
    Vector2f normal = new Vector2f(vertsA[1]);
    normal.sub(vertsA[0]);
    normal.set(normal.y, -normal.x);
    EdgeSweep sweep = new EdgeSweep(normal);
    sweep.insert(0, true, vertsA[0].dot(normal));
    sweep.insert(0, true, vertsA[1].dot(normal));
    sweep.addVerticesToSweep(false, vertsB);
View Full Code Here

   * @param vertsB The polygon's vertices
   */
  public void setLineEndContact(Contact contact, Intersection intersection, Vector2f[] vertsA, Vector2f[] vertsB) {
    Vector2f separation = new Vector2f(intersection.position);
    if ( intersection.isIngoing )
      separation.sub(vertsA[1]);
    else
      separation.sub(vertsA[0]);
   
    float depthA = 0;//separation.length();
   
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.