Package eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.math

Examples of eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.math.Vector2f.sub()


    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


   * 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

    Vector2f[] vertsB = box.getPoints(bodyB.getPosition(), bodyB.getRotation());
   
    // TODO: use a sweepline that has the smallest projection of the box
    // now we use just an arbitrary one
    Vector2f sweepline = new Vector2f(vertsB[1]);
    sweepline.sub(vertsB[2]);
   
    EdgeSweep sweep = new EdgeSweep(sweepline);
   
    sweep.addVerticesToSweep(true, vertsA);
    sweep.addVerticesToSweep(false, vertsB);
View Full Code Here

   * @param vertsB The vertices of polygon B
   * @return the maximum penetration depth along the given normal
   */
  public static float getPenetrationDepth(Intersection in, Intersection out, Vector2f normal, Vector2f[] vertsA, Vector2f[] vertsB) {
    Vector2f sweepdir = new Vector2f(out.position);
    sweepdir.sub(in.position);
   
    PenetrationSweep ps = new PenetrationSweep(normal, sweepdir, in.position, out.position);

    //TODO: most penetrations are very simple, similar to:
    // \               +       |       
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

    // the line A's normal passing through the origin of B
    Vector2f startA = vertsA[0];
    Vector2f endA = vertsA[1];
    ROVector2f startB = bodyB.getPosition();
    Vector2f endB = new Vector2f(endA);
    endB.sub(startA);
    endB.set(endB.y, -endB.x);
//    endB.add(startB);// TODO: inline endB into equations below, this last operation will be useless..
   
    //TODO: reuse mathutil.intersect
//    float d = (endB.y - startB.getY()) * (endA.x - startA.x);
View Full Code Here

          startA.y + uA * (endA.y - startA.y));
    }
   
    Vector2f normal = endB; // reuse of vector object
    normal.set(startB);
    normal.sub(position);
    float distSquared = normal.lengthSquared();
    float radiusSquared = circle.getRadius() * circle.getRadius();
   
    if ( distSquared < radiusSquared ) {
      contacts[0].setPosition(position);
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

    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.